Python Program to Check if a Number is Odd or Even


This content was proof-read by Grammarly. You can Try Grammary for FREE

In this Python program, let’s learn how you can check a given number if it is odd or even.

How to Check if a Number is Odd or Even in Python?

A number is a even number if it is perfectly divisible by 2 i.e if the remainder is 0. In Python, you can use the modulus operator (%) to find the remainder. If the remainder is 0 , the number is a even number. If not, the number is a odd number.


Are you a .NET Developer planning to integrate GraphQL for .NET in your Application? Check out this book
# Author : Abandantcode.com
# Python Program to check if the input number is odd or even.

input = 45

if (input % 2) == 0:
   print("{0} is Even Number".format(input))
else:
   print("{0} is Odd Number".format(input))

Output

45 is Odd Number

In the above program, we use the modulus operator and conditional (if statement) in python to find if the number is odd or even.

%d bloggers like this: