Check if a Number is Odd or Even in Python

Share on facebook
Share on twitter
Share on pinterest

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

Subscribe to our Newsletter

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Share this post with your friends

Share on facebook
Share on google
Share on twitter
Share on linkedin

Leave a Reply

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