BrainyBeauty1217 BrainyBeauty1217
  • 22-12-2020
  • Computers and Technology
contestada

Write a program that uses a while loop to calculate and print the multiples of 3 from 3 to 21. Your program should print each number on a separate line. Expected Output:
3
6
9
12
15
18
21

Respuesta :

goodLizard
goodLizard goodLizard
  • 23-12-2020

Code:

num = 3

while num <= 21:

   print(num)

   num+=3

Output of code:

3

6

9

12

15

18

21

Explanation:

The condition num <= 21 will ensure that the program will only print multiples of 3 up to 21. We set num as 3 since we want to start printing from 3, and we add 3 each time to get the multiples.

Hope this helps :)

Answer Link

Otras preguntas

Juan went on a hiking trip. The first day he walked 18 kilometers. Each day since, he walked 90% of what he walked the day before. What is the total distance Ju
100 Points and Brainliest to whoever helps me!
Which property of loss is caused by the natural disasters
________ refers to the degree to which members are attracted to each other and motivated to stay in the group. Group of answer choices Cohesiveness Authoritativ
"The lady is fair," said the knight. What is the knight's opinion of the lady? Base your answer on the meaning of fair. (RL.4, L.4)
I need a paragraph about 2020 plz
Given the graphs of f(x) =x -7 and g(x) =-5x-1, what is the solution to the equation f() = g(x)?
Can someone please help!
] What caused the Sepoy Rebellion? O All of the Above O Unfair justice system toward Indians O Required to use the Enfield Rifle Finn
what happen if carbon is heated with oxygen? what happens if magnesium is burnt in oxygen? what happens if iron is heated with oxygen?