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 program
  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.
				
					# Take input through the user
num = int(input("Please enter number :"))
# Check whether the number is divisible by 3
if num%3 == 0:
# Print output
    print("Number is divisible by 3")
else:
# Print output
    print("Number is not divisible by 3")
				
			

Output :

				
					Please enter number : 14

Number is not divisible by 3
				
			
				
					Please enter number : 21

Number is divisible by 3
				
			

Related Articles

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

Leave a Comment