justinflowers03 justinflowers03
  • 02-12-2020
  • Computers and Technology
contestada

Review how to write a for loop by choosing the output of this short program.

for counter in range(3):
print(counter * 2)


Please explain it to me, I’m not learning Bc I don’t have a teacher.

Respuesta :

tonb
tonb tonb
  • 02-12-2020

Answer:

The output is:

0

2

4

Explanation:

First of all, the print statement must be indented with a tab, otherwise it is not part of the for loop.

The range(3) creates an array with values 0,1,2. The variable 'counter' gets those values one after another, and the print statement outputs this value doubled, hence the 0, 2 and 4 output.

Ver imagen tonb
Answer Link

Otras preguntas

How does our election law regulate election campaigns?.
Helpp me i neeeeeed hellllp
how many players get inducted in the nfl hall of fame
Which of the following is the graph of
If the tax multiplier is 1. 5 and a $200 billion tax increase is implemented, what is the change in gdp, holding all else constant? (assume the price level stay
A girl throws a doll out of the window 32m high with a velocity of 8m/s. How long will it take the doll to hit the ground? How far did it travel?
What is frozen shoulder? symptoms, treatment and a possible pandemic connection.
What is one danger of taking out a variable rate loan?
Here's a graph of a linear function. Write the equation that describes that function. 8 Express it in slope-intercept form. 6 Enter the correct answer. 4 OOO 2
Can somebody help me ???????