# Python Program to Check if a Number is Odd or Even

In this example, we will write a simple program to take input number from the user and display if it is either odd or even number. To better understand this example, make sure you have knowledge of the following tutorials:-

Loading...

Contents

## Python Program to Check if a Number is Odd or Even using modulus operator:

number = int(input("Enter the number: ")) if number % 2 == 0: print("The number is Even") else: print("The number is Odd")

The output of the above program is:-

Enter the number: 4

The number is Even

The number is Even

## Python Program to Check if a Number is Odd or Even bitwise operator:

number = int(input("Enter the number: ")) if number & 1 == 1: print("The number is Odd") else: print("The number is Even")

The output of the above program is:-

Enter the number: 5

The number is Odd

The number is Odd

Here the bitwise operator checks the value in every bit and to know if it is odd, the last value of binary bit should be 1 i.e. 3 = 11 or 5 = 101.

Loading...