In this example we will show how to judge whether a number is an odd or even number in Python.
Source Code
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# if it is even number, the remainder of dividing 2 is 0, otherwise it is odd number
num = int(input("Please input a number: "))
if (num % 2) == 0:
print("{0} is even number".format(num))
else:
print("{0} is odd number".format(num))
Output:
Please input a number: 67
67 is odd number
Please input a number: 4
4 is even number