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

Factor each completely? A2-7a-18
7,915,878 in word form
What is the analogous position in a state government?
there are 26.2 miles in a marathon write the number of the miles using a fraction
Keisha's parents want to save twenty thousand dollars in her college savings account over the next fifteen years. They have eight thousand dollars to use as an
In what living things are sharp senses and large brains usually found
How do you rename 5,400 as hundreds
Which statement accurately describes the homestead act of 1862?
Where is French still widely spoken in mainland Southeast Asia?
1. 8X7= 2. 9X6= 3. 6X4=