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

Which term is used for the tendency of an object to resist a change in its motion? A. acceleration B. displacement C. momentum D. inertia
- x / 3 = 6 ( solving linear equations )
What percentage of the total mass of KHCO₃ is made up by nonmetallic elements?  a. 17%  b. 83%  c. 61%  d. 20%  e. 50%
what is .27 repeating as a fraction
What is the GCF and LCM of 14 and 28
please help me write an algebraic expression equation.   then solve these percent problems.A $150 leather jacket is going on sale for a 25% discount. How
If S is between R and T, RT=24, RS=x^2+8, and ST= 3x+6 how to find the value of X and if S is the midpoint or not (please show how you got the answer)
A 12-gallon tub has a faucet that lets water in at a rate of 3 gallons per minute, and a drain that lets water out at a rate of 1.5 gallons per minute. If you s
What are the four basic parts found in all cells?
Why are America's founding ideals important?