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

in a parallelogram one angle is 9 times the size of another. find the measures of the angles
where will you find maximum rate of evaporation - ocean, pond or an aquarium? Give reason to support your answer.
A movie starts at 7:00 pm and lasts 108 minutes. What time does the movie end?
simplify (1/x) + (1/(x+h)
Find 4 consecutive odd integers where the product of the two smaller numbers is 64 less than the product of the two larger numbers.
Find 4 consecutive odd integers where the product of the two smaller numbers is 64 less than the product of the two larger numbers.
What number is equivalent to 13/2
where will you find maximum rate of evaporation - ocean, pond or an aquarium? Give reason to support your answer.
the length L of a spring is given by L=(3/4)F + 5 where F is applied force. What force F will produce a length of 8?
How many flags are in this wolld ;)