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

PIIPUOLOVA P = $6000.00, A = $7500.00, t = 5 years
What is the answer to F(-2) =
What caused Mesopotamia and Sumer and civilization to rise and fall
I need help for 8 and 9 plz help and thank you
Which phrase is most likely to be on a shopping bill? A. ajouter au panier B. montant total C. payer avec une carte D. chercher sur l’internet
What is the remainder when 6x+12 is divided by 2x-8.​
Sound waves are a longitudinal wave that have a speed of about 340 m/s when traveling through room temperature air. What is the wavelength of a sound wave that
the world future society Predicts that by the year 2020, airplanes will be able to carry 1400 passengers. Today's biggest jets can carry 600 passengers. What wi
the pituitary gland triggers the production of male and female sex hormones
10. Which of the following is an acceleration? a. 12 m/s2 down b. 5 m/s up c. 8N West