Learn about Python Program to check if a Number is Odd or Even in the below code example. Also, refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Python Program to check if a Number is Odd or Even
# Python program to check given number is an even or odd
# input from user
num = int(input('Enter a number: '))
# check number is even or odd
if(num % 2 == 0):
print('{0} is an even number'.format(num))
else:
print('{0} is an odd number'.format(num))
Output:
Enter a number: 5
5 is an odd 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 : Program to Print Odd Number from 1 to 100