Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python Program to Check if a Number is Odd or Even


The program checks if the number is divisible by 2 using the modulus operator (%). If the remainder is 0, the number is even; otherwise, it is odd.

Steps
  1. Get the user input
  2. Divid the integer value by 2, If the remainder is 0, it is an Even number.
  3. Divid the integer value by 2, If the remainder is 1, it is an Odd number.
Here the example check the given number is odd or even using if,else statement.
Example.py
a = int(input("Enter the Number:")) 
if a % 2 == 0: 
  print("Given number is Even") 
else: 
  print("Given number is Odd")

Output 1

Enter the Number : 10
Given number is Even  

Output 2

Enter the Number : 7
Given number is Odd   

Prev Next