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

what is three fourths plus one third plus two sixths
The law of ____ states that every action has an effect on something else (the idea of cause and effect).
jack bought 3 protein bars for a total of $4.26 which equation could be used to find the cost c on dollars of each protein bar ⓐ c\3= 4.26 ⓑ c\4.26=3 ⓒ 3
The law of ____ states that every action has an effect on something else (the idea of cause and effect).
3x+2y=11 2x+5y=22 help ?
how do you think the Mexican government felt about the idea of Manifest Destiny?
Alberto's birthday is 7 days before Corey's birthday. Alberto's birthday is on the 9th. Write the equation to find Corey's birthday.
Find the slope of y=4
Am artist build a sculpture out of metal and wood that weighs 14.9 kilograms.3/4 of this weight is metal, and the rat is wood. How much does the wood part of th
Which of these descriptions best matches feudalism? A.)a society based on long-lasting and recurring feuds between sections of society B.)a social structure whe