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

A robot's height is 120 centimeters. How tall is the robot in millimeters? Record your answer and fill in the bubbles on your answer document, Be sure to use th
If rose bushes are shipped in boxes of 15 and the class orders 255 bushes, how many boxes is this? Use a ratio table to show your work.
HELP PLEASE ASAP PLEASE
A house painter has $100 to buy paint. If each can of paint costs $10, how many cans of paint can the painter buy?
How are humans impacting biodiversity in ecosystems around the world? Provide two examples to support your claim.
Find the area of the shaded region. Do not label your answer. Round your answer to the nearest tenth.
Help Me Please Thanks
In a Chinese home, the family eat dinner without drinking liquids. True or false
i need help on this also
3x - 5 = 16 solution plssssss​