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

(-6x)(½y)(-⅓z) what is the product?
2. He..... me home in his car.​
Plz answer last question and im lost!
which of the following documentation elements are out of practice forthe medical assistant
Historians and contemporaries called the 1920s the "New Era" because Group of answer choices America emerged from its isolationist stance in foreign affairs the
what opportunity did many colonial countries have after world war ll
what benefits do pupils get from using resources around their community
Where was the cultural center for music during the Baroque Period (city and country)- where were the majority of important/influenal Baroque composers live?
Which four phrases in this excerpt from Robert Stawell Ball's Great Astronomers convey a commendable tone toward Ptolemy's work?
Suppose that prices of a certain model of new homes are normally distributed with a mean of $150,000. Use the 68-95-99.7 rule to find the percentage of buyers w