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

Which of the following would be examples of abiotic factors in a mountain river ecosystem? fish, algae, and sand sand, water, and fish sand, water, and mineral
find the x- and y-intercept of the graph of -9x+7y=27 . State tour based as a whole number of as a improper fraction in simplest form
We are planting the trees in the field ( into passive voice)​
HELLLLLLPPOP HELPPPP
Light energy is part of a larger form of energy known as A. Chemical energy B. Nuclear energy C. Electromagnetic energy D. Elastic energy
A bag contains 42 red, 45 green, 20 yellow, and 32 purple candies. You pick one candy at random. Find the probability that it is green or yellow.
sodium plus chloroform sodium chloride friends in the balance equation home​
Hii! Please helpppp!! This was due like 3 days ago lol
Solve 3x-4>11 if the domain of x is {1,2,3,4,5,6,7,8}
Whats 5867 times 382?