In this python if else program, we will check whether the given number is odd or even.
Odd number:
Odd numbers are those numbers that cannot be divided into two equal parts.
Even number:
even numbers are those numbers that can be divided into two equal parts.
Steps to solve the program
- Take the number as input through the user.
- Using an if-else statement check whether the given number is odd or even.
- If the number is divisible by 2 then it is even else odd.
- Print respective output.
# Take input through the user
num = int(input("Enter a number: "))
# Check for odd and even number
if num%2 == 0:
# Print output
print("It is an even number")
else:
#Print output
print("It is an odd number")
Output :
Enter a number: 23
It is an odd number
Related Articles
Python program to check a given number is part of the Fibonacci series from 1 to 10.
Python program to check authentication with the given username and password.
Python program to validate user_id in the list of user_ids.
Python program to print a square or cube if the given number is divided by 2 or 3 respectively.
Python program to describe the interview process.
Python program to determine whether a given number is available in the list of numbers or not.