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

Draft a constitution of your own school including rules, regulations of the school, rights and duties of students and amendments to be done etc. (any 5 each)
Which of the following would be an appropriate topic for a descriptive essay? a.) my grandmother’s house is a long way away b.) in my mind, I can picture my gra
I need help please :3
the line y=-3x+4 is reflected on the y-axis what is the equation of the reflected line
What are the predominant means by which individuals enter the InfoSec profession?
What wrong of "old nepal" does the poet wants to amend? Explain .
If the nth term of a sequence is 18-8n what is the 8th term
5, the following equation shows the position of a particle in time t, x=at2i + btj where t is in second and x is in meter. A=2m/s2, b=1m/s. Find A, the average
Find the midpoint of the line segment whose endpoints are given. (9,3), (10,- 10)​
Need help with this math question (pic included)