Python program to check a number even or odd

Even numbers:- 2,4,6,8,10,…….,
Odd number:- 1,3,5,7,9,………,

How to

  • If an integer is divide by 2 and gives a remainder 0, then it is a even number.
  • If an integer is divide by 2 and gives a remainder 1, then it is a odd number.
Program
n=int(input("Enter an integer"))
 if (n%2)==0:
     print("{0} is a even number".format(n))
 else:
   print("{0} is a odd number".format(n))

Output:-

Enter an integer 4
4 is a even number

Leave a Reply