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

Write an equation for the following word problem. Tyrone ate 16 hamburgers today, Tyrone's plate had a total of 24 hamburgers on it. How many hamburgers did Tyr
This is a type of government where important decisions are made by state officials instead of elected representatives. a. Meritocracy b. Bureaucracy c. Dynasty
The larger of the two numbers is 4 more than twice the smaller. The difference of the larger number and the smaller number is 6. Find the numbers.
which expression is equivalent to 9(9m+3t)
Please answer the photo of my question I post
(9x-9)(9×+9), your finding the difference between two squares. im have some trouble in how to solve it.​
HELP HELP “Translate the following statement in algebraic expressions.” Problem: One-half of the sum of 8
what is the express form of 1:n 6:12 ​
Find the distance between (6,2) and (0, -6).​
after a third war ended in Florida in 1858. The federal government removed most A Chickasaw B. Creek C Seminole D. Cherokee