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

Describe the religious atmosphere of the United States during the Age of Jackson
the third side of an isosceles triangle is 8 inches shorter than the other two sides the perimeter of the triangle is 70 inches find the length of each side
The movement in metals is what?
Jimmy Carter was the first president since before the Civil War to be from the _____. a. north east b. upper midwest c. deep south d. western pacific
How would you determine which layer is the aqueous layer?
You are applying for a secretary position. You have many skills but which of the following would not be one to include on the application? A) Knowledge of word
What was the effect of the Supreme Court case Marbury v. Madison?
The language production and comprehension centers are located in the left hemisphere in about ____% of the right-handed population.
A larger number is double the sum of 3 and a smaller number. The larger number is 2 less than 3 times the smaller number. If y represents the larger number and
someone please help me serious answers only!!!!