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

What is the slope of (2,3) , (6,7)
How do you say I was born in the Philippines in Spanish
At a store , 24 bottles of water and 6 bags of chips costs $23.40. Five bottles of water and two bags of chips cost $6.60. What is the cost of a single bottle o
How do you say I was born in the Philippines in Spanish
2 friends want to equally share 4/3 feet of rope.What length of rope should ea friend get?
Substitution how do u do it??
What is the Geocentric theory in your own words?
The distance of a wave crest from its resting. position is its. out of A. Wavelength B. Amplitude C. Height
If the angles of a triangle are in ratio 2:3:7 find the measure of all the angles of the triangle
What is 60 divided by 100 and why? ( I got 0.6 but I'm not sure ) plz hurry