Program to check if a number is divisible by 3

In this Python if else program we will check if a number is divisible by 3 or not. Print the number divisible by 3.

Divisibility test: The divisibility rule for 3 states that a number is completely divisible by 3 if the sum of its digits is divisible by 3

Steps to solve the programs
  1. Take a number as input through the user.
  2. Check whether that given number is divisible by 3, using an if else statement.
  3. Print the respective output.
				
					num = int(input("Please enter value :"))
if num%3 ==0:
    print("Number is divisible by 3:", num)
else:
    print("Number is not divisible by 3 :", num)
				
			

Output

				
					Please enter value :21
Number is divisible by 3: 21


Please enter value :25
Number is not divisible by 3 : 25
				
			

get all the numbers divided by 3 from 1 to 30.

Related programs

Leave a Comment