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

the quote "putting yourself in another person's shoes" is another way of describing a. looking at a problem from the other person's viewpoint. b. changing roles
what is the value of the expression? [(1 5)⋅2−5]⋅2
Describe the different layers of earths interior.
fine the distance between p(2,8 and q(5,3)
Claire is giving a presentation at work. Several times during the presentation, she says, "um" or "uh." These are examples of what type of vocalic?
what is the value of the expression 4x−y/2y x when x = 3 and y = 3? −3 1 9 18
describe the 3 types of ecological pyramids
Which of the following is an example of an organism maintaining homeostasis? A. a boy riding a bike B. a cat grooming itself C. a bear nursing her cubs D.
what hispanic american hero made florida a safe place to live work and learn?
Which navigation technique consisted of using the sun, moon, and stars to determine a ship's heading? A. piloting B. dead reckoning C. celestial naviga