Python program to check if a number is odd or even
In this python programming guide, we will learn to write:
program to check if a number is odd or even in python
Program to check if a number is odd or even in Python
The python program to check if a number is odd or even is as follows:
# Owner : TutorialsInhand Author : Devjeet Roy
number = int(input('Enter a number: '))
if number % 2 == 0:
print("The number is even!")
print("The number is odd!")
The output of the python program to check if a number is odd or even is as follows:
PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
Enter a number: 8
The number is even!
Few important tips about this program
1. We take an input from the user and convert it to an integer data type.
2. If the number on being divided by two, leaves a remainder zero, then it is an even number. Else it is an odd number.
Snapshot to write a program in python to input a number and check if the number is odd or even
Would you like to see your article here on tutorialsinhand.
program by tutorialsinhand.com
About the Author
Full Stack Web Developer & Data Science Enthusiast
Page Views :
Published Date :