Check if a Number is Odd or Even in Python

Share on facebook
Share on twitter
Share on linkedin
Share on twitter
Share on tumblr

In this Basic Python Program, we will have a look at “How to Check if a Number is Odd or Even in Python”

Odd Number: A number which is not divisible by 2.

Even number: A number which is divisible by 2.

Python Program To Check if a Number is Odd or Even

num = int(input("Enter a number: "))
if (num % 2) == 0:
   print("{0} is Even".format(num))
else:
   print("{0} is Odd".format(num))

Output:

Enter a number: 1 is Odd

Leave a Comment

Your email address will not be published. Required fields are marked *