Here in this article, we have provided a python source code that checks if the user entered number is an Even or Odd number.
Prerequisite topics to create this program.
- First, we ask the user to enter a number.
- Using the int() function we will convert the entered string into an integer value.
- Using the if….elif and Arithematic modules statement we check for conditions.
Python Program to Check if a Number is Odd or Even:
number = int(input("Enter a Number: ")) if number %2==0: print(number, "is an Even Number") else: print(number,"is an Odd Number")
Enter a Number: 13 13 is an Odd Number
Enter a Number: 100 100 is an Even Number
In this python tutorial, you learned how to check if a number is Odd or Even in python. We generally use the modules % operator to check if the number is completely divisible by 2 or not. If the number is completely divisible by 2, the % operator returns 0 else it returns a non 0 value.
People are also reading:
- WAP to swap two numbers
- WAP in C++ and python to convert temperature from Fahrenheit to Celsius and vice-versa
- WAP in C++ and python to check whether the year is a leap year or not
- Write a C++ Calculator to perform Arithmetic Operations using Switch Case
- WAP in C++ & Python to reverse a number
- WAP in C to calculate the factorial of a number
- WAP in C++ & Python to Insert an Element in an Array
- WAP to convert a given number of days into years, weeks and days
- WAP to check whether the entered number is prime or not
- WAP to find the divisors of a positive Integer