Python Program to Check if a Number is Odd or Even

Posted in

Python Program to Check if a Number is Odd or Even
vinaykhatri

Vinay Khatri
Last updated on November 30, 2023

    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

    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 Comment on this Post

    0 Comments