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

Which vector is the sum of the vectors shown below?
If the equation y=mx+b is used to model a quantity y as a function of the quantity x, why is b considered to be the starting value?
formula for profit and loss
pls do help quickly
the ratio of boys to girls is 4:3 after 160 boys left the ratio of boys to girls is now 4:5 how many girls are left?
Shade the model to show the decimal 0.545
What did the British gain if they won the war of 1812?
URGENT!!!!!!!! Amy is a software saleswoman. Her base salary is $1900 , and she makes an additional $120 for every copy of Math is Fun she sells. Let P rep
In parallelogram ABCD, BC=3x-1, AB=x+11, and AD=2x+2. What is the value of x?
I WILL AWARD BRAINLIEST!!! Find the value of x in each case B, C ∈ AD