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