4.3 Code Practice: Question 2

Students were inquired to answer a question at academics and to claim what is most important for them to succeed. The one which response stood out from the rest was practice. Successful people ordinarily are not born successful; they become successful through hard work and perseverance. If you wish to achieve your goals, keep this in mind! followed below some question and answer examples that you can certainly benefit from to enrich your knowledge and gain insight that will assist you to preserve your school studies.

Question:

4.3 Code Practice: Question 2

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.
(Python)

Answer:

The required program written in python 3 is as follows :

num = 3

#initialize a variable called num to 3

multiples_of_3 = []

#empty list to store all multiples of 3

while num <=21 :

#while loop checks that the range is not exceeded.

if num%3 == 0:

#multiples of 3 have a remainder of 0, when divided by 3.

multiples_of_3.append(num)

#if the number has a remainder of 0, then add the number of the list of multiples

num+=1

#add 1 to proceed to check the next number

print(multiples_of_3)

#print the list

They can potentially hopefully assist the student take care of the question by using the questions and answer examples. Then could make some sharing in a group discussion and also learning with the classmate around the topic, so another student also take up some enlightenment and still keeps up the school learning.

READ MORE  A population of beetles are kept in a controlled ecosystem. No beetles are

Leave a Reply

Your email address will not be published.