Program to get all numbers divided by 3 between 1 to 30

In this Python if else program we will get all numbers within a given range divided by a certain number. It will print all the numbers which are divisible by 3 between 1-30

Hint:
Use for loop with the range function

Steps to solve the program
  1. Use for loop with the range function to iterate over numbers from 1-30.
  2. Using if else statement check whether a  number is divisible by 3 or not.
  3. If it is divisible by 3 then print the number.
				
					# Iterate over numbers from 1-30
for i in range(1,31):
# Check whether number is divisible by 3
    if i%3 == 0:
    # Print output
        print(i,end=" ")
				
			

Output :

				
					3 6 9 12 15 18 21 24 27 30
				
			

Related Articles

check given number is divided by 3 or not.

assign grades as per total marks.

Leave a Comment