In this post we will describe , how to check a input number either even or odd. Before going to describe we need to understand what is a even or odd number in mathematics.

Even Number
A number is called even if it’s divisible by 2 or we can say if the remainder is zero.
Example : Let’s consider number 4.
If we divide 4 by 2 then the remainder will be 0(Zero).
4 / 2 = 2
4 % 2 = 0
So here we can say 4 is a even number.

Odd Number
A number is called Odd if it’s not divisible by 2 or we can say if the remainder is not zero.

Example : Let’s consider 7.
If we divide 7 by 2 the result will be 3 and the remainder is 1.
7 / 2 = 3
7 % 2 =1
So here we can say 7 is not a even number.

Now let’s start writing algorithm for even/odd number. It’s a good practice to write algorithm before writing a program. Because it makes programmer easy to write a program.

Step1: Start
Step3: If Number % 2 == 0 Then print “Number is even” else print “Number is odd”
Step4: Exit

##### Program for even/odd numbers using if else condition
``````#Enter a number to check even/odd
number = int(input("Enter a number: "))
if (number % 2) == 0:
print("The Number is Even")
else:
print("The Number is Odd") ``````

Output:

Program for even/odd numbers using function

``````#Input a number
number=int(input("Enter a number: "))
#function evenodd() starts here
def evenodd(number):

if(number%2==0):
print(number," is an even number")
else:
print(number," is an odd number")
#function evenodd() end here
#function call
evenodd(number)``````