Pythondex
Python Programs

Python Program To Check Even Or Odd Number

Last updated March 7, 2024 by Jarvis Silva

Want to check if number is even or odd in python then you are the right place, In this tutorial we will see how to create a python program to check even or odd number.

Number which when divided by 2 gives remainder as 0 means divisible by 2 is called even number and Number which when divided by 2 does not gives 0 means not divisible by 2 is called odd number.

This is the most simplest defination for even and odd numbers and that is what we are going to use to create this program.

Python code to check even or odd number


num = int(input('Enter a number: '))

if (num % 2) == 0:
    print(f'number {num} is Even')
else:
    print(f'number {num} is Odd')

As you can see from the above code we used the modulus operator % which gives the remainder of numbers when divided, so we compute the remainder of the user entered number and 2.

If we get remainder 0 we print the given number is even else we print number is odd. As you can see it was very simple to check even odd number in python.

You can run the above code in a online python compiler or on your computer and when you run the program you will be asked to enter a number then it will print if the number is even or odd, Below is an example output.


> Enter a number: 10
>> number 10 is Even

So this was the python program to find if a number is even or odd. I hope you found this tutorial helpful and solved your problem.

Want to get the latest updates from our blog then do join our Telegram channel we upload the best python guides and tutorials.

Thanks for reading, have a nice day 🙂