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
Two routes connect an origin and a destination. Routes 1 and 2 have performance functions t1 = 2 + X1 and t2 = 1 + X2, where the
Musya8 [376]

Solution :

Given

$t_1=2+x_1$

$t_2=1+x_2$

Now,

$P(h

$0.4=1-P(h \geq5)$

$0.6=P(h \geq5)$

$0.6= e^{\frac{-x_1 5}{3600}}$

Therefore,   $x_1=368 \ veh/h$

                        $=\frac{368}{1000} = 0.368$

Given,   $t_1=2+x_1$

                 = 2 + 0.368

                 = 2.368 min

At user equilibrium, $t_2=t_1$

∴  $t_2$ = 2.368 min

$t_2=1+x_2$

$2.368=1+x_2$

$x_2 = 1.368$

$x_2 = 1.368 \times 1000$

    = 1368 veh/h

7 0
3 years ago
What is the mass of a brass axle that has a volume of 0.318 cm? ​
NeX [460]

Answer:

2.7g

Explanation:

the mass of a brass axle that has a volume of 0.318 cm is 2.7g.

8 0
3 years ago
A hypothetical A-B alloy of composition 57 wt% B-43 wt% A at some temperature is found to consist of mass fractions of 0.5 for b
Dennis_Churaev [7]

Answer:

composition of alpha phase is 27% B

Explanation:

given data

mass fractions  = 0.5 for both

composition = 57 wt% B-43 wt% A

composition = 87 wt% B-13 wt% A

solution

as by total composition Co = 57 and by beta phase composition  Cβ = 87  

we use here lever rule that is

Wα = Wβ   ...............1

Wα = Wβ = 0.5

now we take here left side of equation

we will get

\frac{C_\beta - Co}{C_\beta - Ca}   = 0.5

\frac{87 - 57}{87 - Ca} = 0.5  

solve it we get

Ca = 27

so composition of alpha phase is 27% B

8 0
3 years ago
Gas is kept in a 0.1 m diameter cylinder under the weight of a 100 kg piston that is held down by a spring with a stiffness k =
Artyom0805 [142]

Answer:

The spring is compressed by 0.275 meters.

Explanation:

For equilibrium of the gas and the piston the pressure exerted by the gas on the piston should be equal to the sum of  weight of the piston and the force the spring exerts on the piston

Mathematically we can write

Force_{pressure}=Force_{spring}+Weight_{piston}

we know that

Force_{pressure}=Pressure\times Area=300\times 10^{3}\times \frac{\pi \times 0.1^2}{4}=750\pi Newtons

Weight_{piston}=mass\times g=100\times 9.81=981Newtons

Now the force exerted by an spring compressed by a distance 'x' is given by Force_{spring}=k\cdot x=5\times 10^{3}\times x

Using the above quatities in the above relation we get

5\times 10^{3}\times x+981=750\pi \\\\\therefore x=\frac{750\pi -981}{5\times 10^{3}}=0.275meters

5 0
3 years ago
Suggest appropriate materials for a cylinder head and give four reason for your choice​
ycow [4]

Answer:

head and give four reason for your choice

7 0
3 years ago
Other questions:
  • 10. What does a profile of a river from its headwaters to its mouth typically show?
    13·1 answer
  • What are the seven problem solving steps?
    12·1 answer
  • The temperature of a gas stream is to be measured by a thermocouple whose junction can be approximated as a 1.2-mm-diameter sphe
    7·1 answer
  • Shear plane angle and shear strain: In an orthogonal cutting operation, the tool has a rake angle = 16°. The chip thickness befo
    7·1 answer
  • A 0.50 m3 drum was filled with 0.49 m3 of liquid water at 25oC and the remaining volume was water vapor without any air. The dru
    15·1 answer
  • What is the most common type of pump?
    11·1 answer
  • What quantity measures the effect of change?
    12·2 answers
  • Explain the use of a vacuum gauge.
    15·1 answer
  • IF A CAR AHEAD OF YOU HAS STOPPED AT A CROSSWALK, YOU SHOULD:
    12·1 answer
  • An ideal vapor-compression refrigeration cycle using refrigerant-134a as the working fluid is used to cool a brine solution to −
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!