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

How does the human body maintain homeostasis regarding temputure?
Which of the following example s from the Canterbury Tale shows Direct Characterization? A. “The monk’s sleeves were garnished at the hand, with fine gray fu
What is 82,964 rounded to the nearest ten thousand?
How did England ensure that it would profit from the crops raised in British colonies?
Why was it difficult for the ottomans to capture Constantinople
Explain what a rodhocetus is
What is the unit of measure of current? what was the original term for the battery? who invented the incandescent light bulb? who invented the fluorescent light
solve the following system of equations 2.5x-1.9y=4.9 -0.5x+1.8y=4.7
Süleyman the Magnificent was a ruler from what empire?
Although it is not directly stated in the order, it was assumed that individuals in Roosevelt’s executive order no. 9066 were targeted for internment because