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]
3 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]3 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]3 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
Which of the following is not hardware? Question 7 options: A) Wireless network router B) Printer C) Virus Scanner D) Flat-panel
jok3333 [9.3K]

the answer is virus scanner which is not hardware but software because if you didn't know hardware is stuff like a monitor a mouse a battery a case that's all stuff you can generally touch even the hardware inside the computer you can touch where as virus scanner you can not touch because its software again my point being its software NOT hardware

8 0
3 years ago
3. How can you correct the color of your photos automatically?​
natita [175]

Answer:

use the lightroom

download the app haha

4 0
3 years ago
Read 2 more answers
In Microsoft Access, what happens when you save a query once and run it but then add more to the query? What will happen? a)erro
Usimov [2.4K]
D)When the query is run again, the data that meets the new criteria will be retrieved.
5 0
3 years ago
1,
sashaice [31]

Answer:

Match the methods:

See attached file

---------------------------------------------------------------------------------------------------------------------------------------

2)

Methods are public, and instance variables are private in common pattern of a class definition program.

So, the correct option is (C).

- -----------------------------------------------------------------------------------------------------------------------------------------

3) Java code:

//Create a Throttle called quiz with 100 positions<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Throttle quiz = new Throttle(100);

//Method that shifts quiz's flow to the halfway

quiz.shift(50);

//Display the current flow from quiz.

System.out.println(quiz.getflow());

-------------------------------------------------------------------------------------------------------

4)

Assume that the Foo class does not have a clone method. Then x is set to refer to a copy of y's object for an assignment x=y; in two Foo objects

.

So, the correct option is (A)

-----------------------------------------------------------------------------------------------------------------------------------------

5)

The correct option is

A)

mower.top and copter.top will always be two separate instance variables.

Explanation:

8 0
3 years ago
Which memory device should Peter use in his digital camera and media player?
Sladkaya [172]
A flash drive can be useful to store memory
3 0
3 years ago
Other questions:
  • Which technology can allow a single ground-based telescope to achieve images as sharp as those from the Hubble Space Telescope?
    7·1 answer
  • Can someone help me with this one
    9·2 answers
  • ? Assessment
    12·1 answer
  • Don is visiting digital stores and searching the internet to learn about high-definition DVD players before he buys one. This is
    8·1 answer
  • Default tab stops are set in word every _______ inch. a. ¾ b. ½ c. 1 d. ¼
    7·1 answer
  • There are ___ Federal Reserve Banks. Each bank is also in charge of its assigned District Banks.
    10·1 answer
  • Persuasion is when Someone speaks to crowd about love <br>○True<br>○False​
    10·1 answer
  • Technical term of stealing personal information in social media.​
    5·1 answer
  • assume there are K sorted lists, each of n/k elements. We want to merge them into a single sorted list of n elements. Give an op
    7·1 answer
  • True of false that the memory of laptop is normally measured in kilobytes
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!