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

4(5x-3)=20x-3 I just need the solution
please in through steps, how would i solve this problem? i have never done this and i want to learn. the problem: 4(2h+g) ty!
The highest sounding member of the woodwind family is the:
(n+n+12)3=84 .......
3 x 7/18 as a fraction in simplest form
Find the Y equation of the line
An electrical generator creates electricity by A) By spinning a turbine with kinetic energy B) By using Gasoline C) By exposing a coil of wire to a changing mag
What can cause a significant change in someone's life
what is the expected outcome of crossing two tomato plants that are heterozygous for hairy stems
Can anyone solve this question from my soldier's heart essay? Before Charley’s first battle, he writes a letter to his mother stating that he is a man (even tho