Python Check if a Number is Odd or Even

In this snippet, we will learn how to check odd/even number in Python.

The Program

The source code of the program:

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

Output 1

Odd number:

Enter a number: 55
The number 55 is odd

Output 2

Even number:

Enter a number: 88
The number 88 is even

Software Engineer | Ethical Hacker & Cybersecurity...

Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.