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

jamie wrote 4.4 - 0.33 = 1.1 . Is his answer resonable? Why or why not?
The length of a rectangle is 50 meters. This is 6 m more than twice the width. Find the width.
Why was the south so upset by lincoln's election in 1860?
another word for not perfect. having a defect
An adult ticket to the zoo cost $20,and a child's ticket cost $10.how much will it cost for mr. And mrs.brown and their four children to get into the zoo?
Archaeologists believe Vinland was located on what continent?
What term is used for the division of political authority among branches of government? a. executive privilege b. federalism c. joint chiefs of staff d. sep
Are all whole numbers a rational numbers
numbers like 10;100;1,000 and so on are called
how do you write one and twelve hundredths in 2 other forms