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

Gagan

Hi, there I'm founder of ComputerScienceHub(Started this to bring useful Computer Science information just at one place). Personally I've been doing JavaScript, Python development since 2015(Been long) - Worked upon couple of Web Development Projects, Did some Data Science stuff using Python. Nowadays primarily I work as Freelance JavaScript Developer(Web Developer) and on side-by-side managing team of Computer Science specialists at ComputerScienceHub.io

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts