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 decimal form of -6 5/16? -6.516 -6.3125
Please help with this question
A student athlete runs 3 miles in 30 minutes.A professional runner can run 1 times as farin 30 minutes. How far can the professionalrunner run in 30 minutes?
Although incineration can break down harmful chemicals, the by-product is hazardous. TRUE or false
The school counseling movement in the United States resulted as a consequence of which major event
During pregnancy, symptoms such as high blood pressure, excess protein in the urine, edema, changes in blood clotting, and seizures are associated with a condit
A postal worker drove 4.3 miles on her morning route and then drove 12.5 miles on her afternoon route. She drove the same distances each day for 8 days.  What w
How many hours will it take to drain the basement? The top question
Three of the following caused the impoverishment of the small farmer class in italy during the 2nd century B.C. which did not? A: the devastation caused by Han
Can I PLEASE PLEASE PLEASE get some help?