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

Propose 5 ways in which the goverment can ensure that the help it offers is recieved only by the people who are needed
What is 12,052 in expanded form
Hi my name is Jasmin I've been having trouble with math. I'm learning how to Multiply fractions, I want to know how to get the correct answer for this problem,.
what is the answer (3/5a6b9)2
Decrease seventy-two hundredths by two tenths. Write the equation used to solve this problem
Some athletes have as little as 3.0% body fat. If such a person has  body  mass of 65 kg,how many pounds of body fat  does  that person have?
if a diagonal lies outside of the polygon then the polygon is concave. True or False
write (y^4)^2 without exponents.
pushing the body harder than is ready to be pushed during exercise
What are actions taken to avoid the effects of a particular risk