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

a loan officer will use _____ to determine if you will be approved for a loan
Why Donald Trump is good/bad choice for the U.S president? Write your pros and cons.
our topic at school is light- What is dispersion, diffusion, refraction and reflection?
Help with these please???
An amateur astronomer thinks he may have seen unusual event in the sky he needs to describe the location to a nearby servatory which of the following should he
what major contribution did Confucius make to the cultural development of China
What macromolecule provides a person with most of the energy that is needed for daily activities?
How many electrons in 0-2?
Which sentence is punctuated correctly? “The show at the Carousel Lounge went well”, said Greg. “The show at the Carousel Lounge went well,” said Greg. “T
Which of the following tools would be used in schools to adapt teaching strategies to the specific needs of students? A. voice recognition software B. text-to-