Python program to check if a number is odd or even

Python Program to check if a number is odd or even

In this article, we will see a python program to check whether a number is odd or even. As we know, a number is said to be even if it is completely divided by 2. In other words, a number is said to be even if it gives a reminder of zero after dividing by 2.

And if a number is not completely divided by 2 then a number will be considered an odd number.

As we know, a number is said to be even if it’s a reminder is equal to zero after dividing by 2.

In Python, “%” is used as a reminder operator (Gives reminder) and “==” is used to equate the equation. We should have basic knowledge of Operators in Python.

Therefore, the condition for checking an even number is :

number%2==0

Hence, if a number is satisfying the above condition, that means the number will be an even number. if a number is not satisfying the above condition, that means the number will be an odd number.

Python program to check if a number is odd or even :

print("Enter a number")
n=int(input())
if(n%2==0):
    print("Entered number is an even number")
else:
    print("Entered number is an odd number")


Output (First run) :

Enter a number
3
Entered number is an odd number

Output (Second Run) :

Enter a number
16
Entered number is an even number

Discover Our Exciting Courses and Quiz

Enroll now to enhance your skills and knowledge!

Python Online Quiz

Level up your coding skills with our interactive programming quiz!