Python | Checks if Number is Odd or Even

Any number is considered even if its divisible by 2, otherwise its considered Odd. Quite simple Mathematically logic, let’s implement this logic as Python Code for Checking if Number is Odd or Even.

Algorithm for Checking if Number is Odd or Even

  • If number is divisible by 2(Remainder comes out to be 0) then its Even
  • If number is not divisible by 2(Remainder not comes out to be 0) then its Odd

Python Code for Checking if Number is Odd/Even

# Ask user for some number
number = int(input("Enter Some Number => "))

# Dividing number by 2
if(number%2 == 0):
	print(number, "is a Even number")
else:
	print(number, "is a Odd number")

Output of Above Code

Enter Some Number => 3
3 is a Odd number

Comments to: Python | Checks if Number is Odd or Even

Your email address will not be published.