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
Nady [450]
3 years ago
10

4.10.1: Simon says. "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user mu

st repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement. Assume simonPattern and userPattern are always the same length. Ex: The following patterns yield a userScore of 4: simonPattern: RRGBRYYBGY userPattern: RRGBBRYBGY
Engineering
1 answer:
AleksandrR [38]3 years ago
5 0

Answer:

for  i  in range(0,10):

   if SimonPattern[i] == UserPattern[i]:

       score = score + 1

       i = i + 1

   else:

       break

if i == 9:

   score = score + 1    

print("Total Score: {}".format(score))

Explanation:

This for loop was made using Python. Full code attached.

  • For loop requires a range of numbers to define the end points. For this Simon Says game, we are talking about 10 characters, so that must be the range for the for loop: from 0 to 10.
  • Conditional if  tests if Simon pattern matches User's one characheter by one and add point for each match.
  • Break statement is ready to escape the for loop at first mismatch.
  • As we are starting from index 0, if the users matched all the characters correctly, then we need to add 1, otherwise the maximun score would be 9 and it should be 10.
Download txt
You might be interested in
What is the smallest variable type I can use to represent the number 27?
oksano4ka [1.4K]

Answer:3

Explanation:

Cuz

3 0
3 years ago
8. Question You should never drive: When weather conditions are not ideal. When road conditions are not ideal. Without having ma
LiRa [457]
The answer is All of the above
6 0
2 years ago
4. Which 2D shape on the left would be used to make the 3D shape on the right? (1 pt.)
dexar [7]

it would be a bc its a sqare?well 3d is like you can say a cube 2d is like flat

Explanation:

7 0
2 years ago
Three natural materials that were used by early man as roof covering​
olga55 [171]

Explanation:

animal parts, wood, rock, and clay

8 0
2 years ago
Read 2 more answers
Fill in the blank to correctly complete the statement below.
lapo4ka [179]

Explanation:

The invention of the pendulums driver ____ ao in the 1600s paved the way for a new industrial era. Add answer.

6 0
3 years ago
Other questions:
  • Which is the correct order for handwashing
    11·2 answers
  • A stream of air enters a 7.00-cm ID pipe at a velocity of 30.0 m/s at 27.0°C and 1.80 bar (gauge). At a point downstrream, the a
    15·1 answer
  • For a column that is pinned at both ends, the critical buckling load can be calculated as, Pcr = π2 E I /L^2 where E is Young's
    9·1 answer
  • A vacuum gage connected to a tank reads 30 kPa at a location where the barometric reading is 755 mmHg. Determine the absolute pr
    14·1 answer
  • stimate the maximum efficiency of an automobile engine that has a compression ratio of 5:1.0. Assume the engine operates accordi
    11·1 answer
  • Describe what viscoelastic behavior means
    7·1 answer
  • Is the gap store an example of commercial construction? Yes or no
    10·1 answer
  • Based on your reading of the following, how does a triple save a fire department in time?
    5·1 answer
  • Which type of boot authentication is more secure?
    11·1 answer
  • To put out a class D metal fire, you must _______ the fire.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!