Write a python program to check if it is an odd or even number using if condition.

 As we all know, every number which is divisible by 2 we call it as even and the number which is not divisible by 2 we call it as odd.

In Python, we have an Arithmetic Operator called % (Modulus) to see the remainder. We will use it to find out whether a number is odd or even.

Code:

a= int(input("Enter a number:"))

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



Output:

First, let's check with an odd number:

Enter a number:55
Entered number is an odd number
 


Now, with an even number:

Enter a number:20
Entered number is an even number

 


 



Comments

Popular posts from this blog

Write a program to input two numbers and inter change their values in python IDLE.