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

please narrate every step you make and make a 2 column proof!thank you!!
Wow! You now know so much about Peru! Your friend Jordan, however, knows nothing about it. In a few months, his family is going on a tour of Spanish-speaking co
Who Is The Lady Massiah
Question 4 of 4 Read this excerpt from James Baldwin's *Notes of a Native Son": The day of my father's funeral had also been my nineteenth birthday. As we drove
I need help please :3
Given (x – 7)2 = 36, select the values of x.
Can somebody please answer asap for brainlist and correct answer?
Need help (pic included)
Read the excerpt from Malala Yousafzai's speech at the United Nations The terrorists are misusing the name of Islam and Pashtun society for their own personal b
Listen and select the option with the spelled word from the audio. Caro Cara Coro Cura