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

Helpppppppppppppppppp
According to Wollstonecraft, people who are only the objects of pity and condescending love will eventually become objects of — a. truer love c. indifference b.
What does null mean?
The width of a rectangle is 3 feet shorter than its length. The perimeter is 530 feet. Let x equal the length of the rectangle. The formula is P = 2l + 2w.
which one of the following voltages should never be measured directly with a VOM? A. 1200 V B. 500 V C. 800 V D. 100V
what is the length of DE ?
The main reason conflict has borken out in northern ireland is because of
Tamera bought green and blue t-shirts as gifts. A green t-shirt costs $4.75, while a blue t-shirt costs $5.25. Tamera spent $95.75 on 19 t-shirts. Let g represe
Please hep 3. Please refer to Story A1 and answer the following question. Which of the following words would best fit into the blank in the final sentence of t
Choose the sentence that accurately expresses a hurt back. Me duele la mano. Me duele la espalda. Me duele el cuello. Me duele el brazo.