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 are subplots from the book Where the Red Fern Grows that were removed in the 2003 movie? PLEASE HELP ME!!!!!
Why would the people not support public education in the early years of the country? Public education would require large amounts of tax dollars. Education was
To which level of government was the power of fire and police protection, schools, and highways and roads given? federal government state governments
Jackson middle school has 6 students in choir for every 1 student in band. if there are 54 students in band, how many students are in choir?
A Savanna is likely to be found in _____
What a double fact of 4+3
Help with 9 please and fast
what can act as a buffer against unemployment
Find the greatest common monomial factor : 4a^5b^2 and ab
Which planet's temperature is closest to that of Earth? (Note: Water boils at 100°C/212°F. Water freezes at 0°C/32°F)