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

Compounds are neutral substances. true false
Help me out plzz and I'll do the same
a university would like to create a circular eating area with picnic tables. the eating area will have small plants that make a path to create individual sectio
Cardiovascular disease relates to disorders of the heart, blood vessels, and lung function.
Which planet has the largest day-night temperature difference?
in metals, the properties of malleability and ductility are explained by the fact that metallic atoms can roll past metallic bonds and form new bonds. roll over
day and night kennel charges $20 per day plus a food fee of $15 to board a pet. home away from home kennel charges $30 per day plus a food fee of $5. which syst
which expression represents the amount of money john has collected? john collects $5 for club dues from each member.
Select all of the abstract nouns. love passion heart peace book determination airplane humor
what is the best plan for creating safe exercise goals -keep them fun -keep them low intensity -keep them realistic -keep them high intensity