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

How are making weapons as dangerous as using weapons? what are the human costs
Plasma makes the blood appear red. True False
What were the 3 main goals os the lewis and clark expediction?
What do soft roadbeds and weak bridges lead to??
Phil has 1/2 pound of berries to put equally into 4 tarts. how many pounds of berries will there be in each tart?
Which action would be considered an instance of plagiarism? A. Not using facts or evidence to support your central thesis statement B. Not using a thesis
Solve the equation on the interval [0, 2pi) 2 cos^2 (theta/2) - 3 cos theta = 0
What government does the philippines have?
Barium chlorate (ba(clo3)2) breaks down to form barium chloride and oxygen. what is the balanced equation for this reaction? when counting atoms in parentheses,
Es importante que_____ bien. A. dormimos B. dormir C. duermieron D. durmamos