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

What are the benefits of volunteering?
What was prohibited by the 18th amendment?
What is the approximate area of a circle whose radius is 3 m long? (Use 3.14 for pi.)
The Joint Information System is
the volume of the cube is 512in3 what is the side length
To maintain order within their cells and organs, all living things must a. constantly change. b. be able to move. c. reproduce. d. carry on metabolism. e. extr
Sponges have flagellated cells called _____ that line their internal chambers and create water flow to capture food. collar cells choanocytes endoderm mesoderm
What do we call the visible streak of light created by space debris entering Earth's atmosphere? A. meteor B. asteroid C. meteorite D. meteoroid
Which of the following freedoms does the First Amendment include? the freedom to bear arms and the freedom of speech the freedom of assembly and the freedom of
how to write 41.344 in word form