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

Your broker faxed to you the following information about two semiannual coupon bonds that you are considering as a potential investment. Unfortunately, your fax
який характер у месі​
Followed Madison as Commander-in-Chief Acolyte of the Democratic-Republican Party Issued foreign policy statement warning European countries away from the Ameri
4. I washed my car. - Present & Future: Present- Washe washedir my car you Future-wash my 5. The police search for the robbers. - Past & Future: Past. T
calculate the number of atoms in 2.5 moles of sodium
Write the balanced equation and determine the information requested. Don't worry about state symbols in these reactions. The number of moles and the mass (in mi
What allow the peripheral proteins?
jxbjsb x x g sssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssss
express x in terms of a and b x/a+1=b
HELPPPPPPPPPP PLEASEEEEEEEE!!!!!!