1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Kisachek [45]
2 years ago
10

"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequen

ce. Create a for loop that compares the two strings. For each match, add one point to user_score. Upon a mismatch, end the game.
Sample output with inputs: 'RRGBRYYBGY' 'RRGBBRYBGY'
User score: 4
in python please
Computers and Technology
2 answers:
Neporo4naja [7]2 years ago
7 0

Answer:

import random

validletters=["R", "G", "B", "Y"]

input1 = ""

for i in range(1,11):

     input1 = input1 + random.choice(validletters)

input2 = input("Input String 2: ")

if len(input2) != 10:

     print("Invalid Length")

else:

     user_score = 0

     for i in range(0,10):

           if(input1[i] == input2[i]):

                 user_score = user_score + 1

           else:

                 break

     print("String: "+input1)

     print("Guess: "+input2)

     print("User Score: "+str(user_score))

Explanation:

The code assumes that user input will always be R, G, B or Y

The next two lines get two string user inputs

import random

This lists the valid letters

validletters=["R", "G", "B", "Y"]

This initializes an empty string

input1 = ""

The following iteration generates the input string of 10 characters

<em>for i in range(1,11): </em>

<em>      input1 = input1 + random.choice(validletters) </em>

This prompts user for input string

input2 = input("Input String 2: ")

This checks if input string is up to length of 10

if len(input2) != 10:

If yes, it prints invalid length

     print("Invalid Length")

else:

If otherwise, user_score is initialized to 0

     user_score = 0

The following iteration checks for matching characters in both strings

<em>      for i in range(0,10): </em>

<em>            if(input1[i] == input2[i]): </em>

<em>                  user_score = user_score + 1  </em><em>This increments user_score by 1 if there is a match</em>

<em>            else: </em>

<em>                  break  </em><em>This ends the program if there is no match</em>

The next three lines print the strings and the user score

     print("String: "+input1)

     print("Guess: "+input2)

     print("User Score: "+str(user_score))

Aleksandr [31]2 years ago
6 0

import random

letters=["R", "G", "B", "Y"]

i = 0

to_guess = ""

while i < 10:

   to_guess += random.choice(letters)

   i += 1

print("Simon says "+to_guess)

user_score = 0

user = input()

for x in range(0, len(to_guess)):

   try:

       if user[x] == to_guess[x]:

           user_score += 1

       else:

           break

   except IndexError:

       break

print("User score: "+str(user_score))

I hope this helps!

You might be interested in
10. Which of these is not an HTTP verb? PUT AJAX GET DELETE
Korolek [52]

Answer:

Brainliest!

Explanation:

The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT, PATCH, and DELETE. These correspond to create, read, update, and delete (or CRUD) operations, respectively. There are a number of other verbs, too, but are utilized less frequently.

-

restapitutorial

.

com

3 0
3 years ago
In today's classrooms, computers are generally being used to
Vinvika [58]
The answer is enhance traditional instruction. Computers are often used by teachers so that the teachers may have an easier time with their visual aids. Now that we have tools like powerpoint presentations and excel files, it will be easier for the teachers to prepare 
4 0
3 years ago
You manage a network that uses a single switch. All ports within your building connect through the single switch. In the lobby o
Karo-lina-s [1.5K]

Answer:

<u>VLANs</u>

Explanation:

Virtual LANs (VLANs) are a type of network connection or arrangement of network devices in the same broadcast domain. They are called Virtual LANs because they represent fractions or subgroups in the switch ports found in an Ethernet LAN.

Indeed, because of their topological arrangement, this reduces the security risk of unauthorized access to sensitive data or devices since the host can be placed on a different VLAN. Hence, in this scenario, using this network feature would allow visitors to plug into these ports to gain internet access, but they would not have access to any other devices on the private network.

5 0
2 years ago
If a wire has insulation that allows it to operate in a temperature of up to 194 degrees Fahrenheit, what temperature will the w
zzz [600]
(194°F-32)×5/9
= 90°C
therefore the answer is 90degrees Celcius
6 0
3 years ago
______ is data that is entered into a computer. ______ is the result produced by a computer.
Umnica [9.8K]
Input
Output
(Sorry for not being detailed)
5 0
3 years ago
Other questions:
  • The ____ cell on the worksheet is the one into which you can enter data.â
    15·2 answers
  • Which of the following is NOT a web browser?<br> Safari<br> Chrome<br> Bing<br> Firefox
    8·2 answers
  • If your BAL is .10 you can expect a _______ drop in complex performance compared to the sober level
    6·1 answer
  • Describe one type of technology that is useful in producing images from space.
    9·1 answer
  • Given the code segment below, complete the assignments as stated in the comments. struct aaa { int m; int nn; } struct bbb{ stru
    13·1 answer
  • HELP 25 POINTS!!!!!
    6·2 answers
  • Suppose you own a travel agency in a large city. You have many corporate clients, but growth has slowed somewhat Some long-term
    15·1 answer
  • The process of identifying and eliminating bugs in a software program is most generally called
    5·1 answer
  • Using direct mapping, consider a 16-bit memory addresses, and a cache with 64 blocks, where each block is 8 bytes. What is the s
    8·1 answer
  • If each integer occupies one 64-bit memory cell and is stored using sign/magnitude notation, what are the largest (in terms of a
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!