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

Does a right triangle have perpendicular sides? Does a quadrilateral have perpendicular sides?
A) Pongo _______ en la lavaplatos B) seco la ropa en ______. C) uso el cortacesped para cortar _____. D) pongo _______ en la Cama E) me bano en ______. F) t
Why Shi Huangdi was effective
Consider any set of three adjacent elements in the same period on the periodic table. for which characteristic is the average for the three elements always equa
In what way does the stone calendar reflect beliefs of the Aztecs? A. The spirits of the deceased used it as a guide through the afterlife. B. People used it to
what happens if cells were in mitosis more than they were interphase
An African cheetah can run at speeds up to 120 kilometers per hour. What is this speed in feet per second? I need help sorry I struggle a lot with these kinds o
A warm and dry air mass would probably have begun
The words the anchor says in between stories are called what
The function F(x)=log5^x is decreasing.