Python program to check if number is even or odd

In this post, we will see how to check if number is even or odd in python.

It is very simple to check if number is odd or even.

  • We just need to check this condition num%2==0
  • if num%2==0 then number is even
  • if num%2==1 then number is odd

Let’s write a simple python function to check if number is odd or even.

def oddOrEven(num): if(num%2==0): return "Even" else: return "Odd" #Testing the function print("12 is",oddOrEven(12),"number") print("35 is",oddOrEven(35),"number")

Output:

12 is Even number
35 is Odd number

That’s all about python program to check if number is even or odd.

Leave a Reply

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