Python program to check whether a number is odd or even

Python program to check whether a number is odd or even

Python program to check whether a number is odd or even

Concepts Required:

  1. if else statement
  2. arithmetic operator


Python program to check whether a number is odd or even


Explanation

How to find whether a number is even or not? If the number is divisible by 2 then it is even else it is odd. We will use this logic to make the program.



Code

num = int(input("Enter your number: "))

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



Output

Enter your number: 5
5 is an odd number


In this program we are checking if the remainder is 0 when a number is divided by zero. Then print even and otherwise it will be odd.

Load comments