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 .00185 as a fraction
what is the advantage of timing for a full minute to find your pulse?
Study Island- Rational & Irrational Numbers
what is the meaning of battle-sweat
which best explains what a word root is? a. the part that carries the word's meaning b. letters added to the end of a word c. letters at the beginning of a word
which nucleic acid moves the code for protein synthesis from the nucleus to the ribosomes
The media play an important role in shaping the _____, which includes the issues on which the public’s attention is focused.
How many hours will it take the human body to fully digest a meal? A . 3 hours B. 6 hours C. 5 hours D. 9 hours E. None of the above
may someone help me out with this please
During the 1920s, more people began to aquire shares of stock using credit. cash. installments. speculation.