Easy Tutorial
❮ Python Att Dictionary In Html Python Os Pardir ❯

Python Odd or Even Number Check

Python3 Examples

The following example is used to determine if a number is odd or even:

Example (Python 3.0+)

# Filename : test.py
# author by : www.tutorialpro.org

# Python Odd or Even Number Check
# If the number is even, the remainder when divided by 2 is 0
# If the remainder is 1, the number is odd

num = int(input("Enter a number: "))
if (num % 2) == 0:
   print("{0} is even".format(num))
else:
   print("{0} is odd".format(num))

We can also use an embedded if statement to achieve this:

Executing the above code will output:

Enter a number: 3
3 is odd

Python3 Examples

❮ Python Att Dictionary In Html Python Os Pardir ❯