Python program to check odd even number
Following Python program will read a number from user and will display whether it is odd or even.
To check whether given number is ODD or EVEN, program uses modulus operator (%) and divides given number by 2. If the answer of modulus operator is 0; it means given number is completely divisible by 2, hence we can display that "It's even number". If answer of modulus operator is not zero, it means number is Odd.
#Python program to check odd-even number.
number = int(input("Enter your number:"))
if (number%2 == 0):
print("It's even number")
else:
print("It's odd number")
number = int(input("Enter your number:"))
if (number%2 == 0):
print("It's even number")
else:
print("It's odd number")
Output of program
Enter your number:101
It's odd number
* * * * *
No comments:
Post a Comment