Python program to check whether a number is even or odd

Python program to check whether a number is even or odd. In Python, this program can determine whether a value is odd or even. Small children should figure out which number is odd and which is even, but they must learn how to do so in a programming language.

a = int(input("Enter the number to find odd or even "))
if (a % 2) == 0:
print("{0} is Even".format(a))
else:
print("{0} is Odd".format(a))

 

Output:

Enter a number: 45

odd

What is odd or even number in python program

The integer entered by the user is stored in the variable num in the program. The modulus percent operator is then used to determine whether num is perfectly divisible by 2. The test statement number percent 2 == 0 evaluates to 1 if the number is completely divisible by 2.