⊕
⊖
Contents
Python Program to Check if Number is Even
To check if given number is even or not in Python, we can divide the given number by 2 and find the remainder. If the remainder is equal to zero, then the given number is even, or else not.
Condition
If n is given number, then the boolean condition to check if n is even is
n % 2 == 0
Example
In the following program, we take an integer value in n, and check if this number is even or not.
Python Program
n = 10
if ( n % 2 == 0 ) :
print(f'{n} is even number.')
else :
print(f'{n} is not even number.')
Run Code CopyOutput
10 is even number.
Summary
In this tutorial of Python Examples, we learned how to check if a given number is an even number or not.