Skip to content
Home » Program to Check if the Number is Odd in Python

Program to Check if the Number is Odd in Python

Learn about Program to Check if the Number is Odd 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.

Program to Check if the Number is Odd in Python

# Python program to check given number is an odd or not

# input from user
num = int(input('Enter a number: '))

# check number is odd or not
if(num % 2 != 0):
 print('{0} is an odd number'.format(num))
else:
 print('{0} is not an odd number'.format(num))

Output:

Enter a number: 7
7 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 : Python Program to Print All Even Numbers in a Range