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

Alcohol poisoning is a likely result of
What shapes could the smaller pieces be?
What is the rational number equivalent to
Rewrite the sentence using an absolute phrase for "he wanted a car"
What is the conversion of 160g to cg??
What was the liberator?
True false: sister chromatids are created for each of the multiple chromosomes found in the cell's nucleus.
List some if the inventions or discoveries from the stone age that are still in use today
Two minerals mentioned in this section which are stored in the bones are: Magnesium Calcium Potassium Phosphorus
Help me fast plz!!!!!!!!!!What is the remainder when 15,908 is divided by 13?