Even number
Even numbers are numbers that have a difference of 2 unit or number. In other words, if the number is completely divisible by 2 then it is an even number.
Odd number
Opposite of even numbers, odd numbers are having a difference of 3 unit or number. In other words, if the number is not completely divisible by 2 then it is an odd number.
Logic
To find if a number is even or odd we only need to check if the given number is multiple of 2 or not, If it is multiple of 2 that means it is even number otherwise an odd number.
To check if it is multiple of 2 or not we use modulus operator.
If the expression number % 2 returns 0 that means the number is a multiple of 2. In other words, it is completely divisible by 2.
Program
# Take one integer number from user number = int(input("Enter an integer : ")) # Check for odd / even if number % 2 == 0 : print("\n" + str(number), "is even number.") else : print("\n" + str(number), "is odd number.")
Output
Enter an integer : 886
886 is even number.