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

The gene for a widow's peak is dominant. A child inherits genes with the genotype: Ww and Ww. What are the chances that he will have a widow's peak? 25% chance
Could you answer the question in the image?
how does a fetus get nourishment up until the time is born
Because different nations have vastly different numbers of people living in them, Gross Domestic Product (GDP) is a very poor way to compare the economic well-b
Make a sentence out of these words and you will be my hero! Distrust,Uncertain,Incomplete,Unlikely,Unfair,Discontinue,Unaware,Disorder,Discount,Indirect,Unopene
~PLEASE HELP~ *Dealing with ratios*
all of the following can be used by writers to foreshadow events in a story except:The answer choices are a sudden change in setting the sequence of plot events
what is 6 8/9 times 2 1/2
A MAJOR cause of imperialism in Africa after 1870 was Europe's desire __________. a. for skilled workers b. to import hand-made products c. for new technology d
why where the loyalists important?