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

In estimating the profitability of a catering business, _______ is most likely to be considered a fixed expense in your overhead costs. a. rental equipment b.
Describe the position of all the points on the number line that are a. greater than a b. less than a
Can you guys help me with this one?! Please please
Can someone help me with this problem? I suck at math .-.
The nile river runs through which of the following countries?
All of the following are results of the Meiji reforms except the _____. construction of railroads creation of the Diet parliament establishment of a new e
Which one of the following statements concerning clothing for cold-weather physical activity is most accurate? A. Wear multiple layers of thin clothing. B
Which is equivalent to 3x/x-7 - x+7/x? A) 2x^2+49/x(x-7) B) x^2+49/x(x-7) C) 2(x+7)/x(x-7) D) 2(x-7)/x(x-7)
How many atoms of copper are in a quarter?
What ethical issues arise in the conversations about cloning? What is the primary argument used by those who advocate human cloning? Is organ cloning considered