4.3 Code Practice: Question 2 [Intructions shown]
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

43 Code Practice Question 2 Intructions shown Write a program that uses a while loop to calculate and print the multiples of 3 from 3 to 21 Your program should class=

Respuesta :

Answer:

i = 3

while(i <= 21):

   if (i % 3 == 0):

      print(i)

      i += 3

Explanation:

fichoh

The program prints all the multiples of three up to 21. The program ls written in python 3 thus :

n = 3

#this is the starting point of the number to be printed

while n <= 21 :

#using a while loop, we iterate up till 21 as we do not want the Values printed to be more than the maximum. Hence, the loop continues until N is greater than 21

print(n, '\n')

#displays the value of n, followed by a new line.

n+=3

#adds 3 to the value of n after each iteration.

A sample run of the program is attached.

Learn more :https://brainly.com/question/16102577

Ver imagen fichoh
RELAXING NOICE
Relax