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 were the major causes of WWII? Please include at least 4 answers.
Simplify the expressions: cot 0 sec 0 A. Sin0 B. Csc0 C. Cos0 D. Cos* 0
What is the amplitude of y=1/2 sin2x
What is the least common denominator for 5/6 and 3/8. 3/4 and 6/7
How do you?...Multiply out and simplify 10(2x-1)-20x?
you have a standard deck of 52 cards. you pick one card and then, with out putting the first card back, you pick a second card. what is the probability that bot
What is the amplitude of y=1/2 sin2x
The function of the eardrum in the middle ear is to
you have a standard deck of 52 cards. you pick one card and then, with out putting the first card back, you pick a second card. what is the probability that bot
The function of the eardrum in the middle ear is to