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
Write two scnr.nextInt statements to get input values into birthMonth and birthYear. Then write a statement to output the month,
aalyn [17]

Answer:

import java.util.Scanner;

public class InputExample {

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       int birthMonth;

       int birthYear;

       birthMonth = scnr.nextInt();

       birthYear = scnr.nextInt();

       System.out.println(birthMonth+"/"+birthYear);

   }

}

3 0
3 years ago
Plis 3 conclusiones de este video
vazorg [7]
No hay videos? de cual video estás hablando?
6 0
2 years ago
Risks can be changed.<br> True<br> False
Mrrafil [7]

Answer:

true

Explanation:

8 0
2 years ago
True or false a critique of hazwoper incidents that have occurred in the past year should not be included in hazwoper 8 hour ref
Jobisdone [24]

Answer:

False

Explanation:

No matter if something happened in the past year or so, it still should be included for safety reasons so it wont happen again

7 0
3 years ago
It is said that Archimedes discovered the buoyancy laws when asked by King Hiero of Syracuse to determine whether his new crown
sertanlavr [38]

Answer with Explanation:

The crown will be pure if it's specific gravity is 19.3

Now by definition of specific gravity it is the ratio between the weight of an object to the weight of water of equal volume

Since it is given that the weight of the crown is 11.8 N we need to find it's volume

Now According to Archimedes principle when the crown is immersed into water the water shall exert a force in upwards direction on the crown with a magnitude equaling to weight of the water displaced by the crown

Mathematically this is the difference between the weight of the crown in air and weight when immersed in water

Thus Buoyant force is F_{B}=11.8-10.9=0.9N

Now by Archimedes principle This force equals in magnitude to the weight of water of same volume as of the crown

Thus the specific gravity of the crown equals

S.G=\frac{11.8}{0.9}=13.11

As we see that the specific gravity of the crown material is less than that of pure gold hence we conclude that it is impure.  

4 0
3 years ago
Other questions:
  • Your program should read from an input file, which will contain one or more test cases. Each test case consists of one line cont
    14·1 answer
  • Work-producing devices that operate on reversible processes deliver the most work, and work-consuming devices that operate on re
    6·1 answer
  • How does heat conduction differ from convection?
    6·2 answers
  • The steel 4140 steel contains 0.4% C, however, it shows higher yield strength and ultimate strength than that of the 1045 (0.45%
    14·1 answer
  • Matthew wants to manufacture a large quantity of products with standardized products having less variety. Which type of producti
    5·1 answer
  • When we utilize a visualization on paper/screen, that visualization is limited to exploring: Group of answer choices Relationshi
    9·1 answer
  • Basic output with variables (Java) This zyLab activity is intended for students to prepare for a larger programming assignment.
    7·1 answer
  • A fatigue test was conducted in which the mean stress was 46.2 MPa and the stress amplitude was 219 MPa.
    12·1 answer
  • Parallel circuits???
    9·1 answer
  • What material are the rocker/valve cover gaskets made out of?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!