Even numbers are those numbers which are divided by 2, and odd numbers are those who don’t fully divide by 2. we will see Python Even odd example in this post.
So To check whether number is even or odd, we will use Modulus operator (%) of Python. % Modulus operator gives the remainder after dividing the numbers.
Python Even Odd example
#Python even odd example number=int(input("Enter number :")) if(number%2==0) : print("Number is Even") else : print("Number is odd")
Enter number :434 Number is Even
Enter number :567 odd
In above example, modulus operator is used to check whether number is divided by 2 will fully divided or not.
we use input function of Python to take input from user through console.
first time when user enter 434 , if condition is true as 434 is fully divided by 2. so output is “Number is Even”
2nd time when we enter 567, else part executed, as 567 is not fully divided by 2.
You can try at your end by putting any number.