Python Program to Check if a Number is Odd or Even

By | October 3, 2021
Python Program to Check if a Number is Odd or Even

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.

Steps

  • 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:

Code

number = int(input("Enter a Number: "))
if number %2==0:
    print(number, "is an Even Number")
else:
    print(number,"is an Odd Number")

Output 1:

Enter a Number: 13
13 is an Odd Number

Output 2:

Enter a Number: 100
100 is an Even Number

 

Vamware

Conclusion

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:

Leave a Reply

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