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

Video club A charged $10 for membership and $3 for movie rental. Video Club B charges $15 for membership and $2 per movie rental. For how many movie rentals wil
If 2x+z=2y and 2x+2y+z=20 what is the value of y?
What is 574 in expanded form
The shape of the clock is a regular dodecagon with a radius of 14cm. Centered on the clock's face is a green circle of radius 9cm. If the region outside the cir
translate into an equation. Five times the sum of twice a number, x, and six is thirty. Find the number.x = Translate into an equation. The difference b
What military strategy defeated cornwallis at yorktown?
my teddy bear gave me a hug is an example of 1.metaphor 2.personification 3.simile 4.alliteration
true or false a trapezoid is a polygon, so all polygons are trapezoid. explain.
how many rectangular prism can you make out of 20 snap of cubes
Describe what happens when blood in capillaries flows past cells