Learn about Check if the Number is Even in Python in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Check if the Number is Even in Python
# Python program to check given number is an even or not
# input from user
num = int(input('Enter a number: '))
# check number is even or not
if(num % 2 == 0):
print('{0} is an even number'.format(num))
else:
print('{0} is not an even number'.format(num))
Output:
Enter a number: 6
6 is an even number
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Even Number Python Program