Odd Number Program


Python Program to Check if Number is Odd

To check if given number is odd or not in Python, we can divide the given number by 2 and find the remainder. If the remainder is equal to one, then the given number is odd, or else not.

Condition

If n is given number, then the boolean condition to check if n is odd is

n % 2 == 1

Example

In the following program, we take an integer value in n, and check if this number is odd or not.

Python Program

n = 13

if ( n % 2 == 1 ) :
    print(f'{n} is odd number.')
else :
    print(f'{n} is not odd number.')

Output

13 is odd number.

Summary

In this tutorial of Python Examples, we learned how to check if a given number is an odd number or not.