Python Program to Check Odd or Even

Introduction

 
In this blog, I am showing you different ways to check that number is even or odd.
 
Check even / odd using modulus operator:
  1. #Even Odd Program using Modulus Operator  
  2. a=int(input("Please Enter a Number : "));  
  3. if(a%2==0):  
  4.     print("This Number is Even")  
  5. else:  
  6.     print("This Number is Odd")  
Check even / odd using bitwise operator:
  1. #Even Odd Program using Bitwise Operator  
  2. a=int(input("Please Enter a Number : "));  
  3. if(a&1==1):  
  4.     print("This Number is Odd")    
  5. else:  
  6.     print("This Number is Even")   
Check Even / Odd without using modulus or bitwise operator:
  1. #Even Odd Program using Modulus Operator  
  2. number=int(input("Please Enter a Number : "));  
  3. x=int(number/2)*2;  
  4. if(x==number):  
  5.     print("This Number is Even")    
  6. else:  
  7.     print("This Number is Odd")