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

Which are the most frequently used words in Spanish?.
determine the next three terms of 0,10,21,33,46,60​
What happened to Leonardo da Vinci in the mysterious cave?.
people living in coastal areas have to paint their window frames frequently and why?​
Which title is capitalized correctly? 1. Lila In the Ice cream 2. the Monkey and Me 3. Peter Goes away 4. The Paper Syndrome Answer for points
What is the mass of an object that is moving at 8.0 m/s and has 70.0 J of kinetic energy?
Although emmanuel goldstein most likely does not exist, how does he help the party?.
Which person's first credit card offer is most likely to put them at risk? A. Carol's card has a low credit limit for the first six months she uses it. B. Micho
Examine the classification chart for animal groups shown here. Which statement BEST describes how the groups of organisms are categorized above? A) Fish and amp
Given the polynomial 2x3 18x2 − 18x − 162, what is the value of the constant 'k' in the factored form? 2x3 18x2 − 18x − 162 = 2(x k)(x − k)(x 9) 3 6 9 18.