Python Program to Check Even or Odd Number
easyif / elsePython
The simplest decision-making program. It introduces the modulus operator %, which gives the remainder of a division.
The question
Read an integer and print Even if it is even, otherwise print Odd.
The code
Input
723
Output
Odd
How it works
- 1n % 2 is the remainder when n is divided by 2 — it is always 0 or 1.
- 2If the remainder is 0, the number divides exactly by 2, so it is even.
- 3Otherwise the else block runs and prints Odd.
Common mistakes
- Writing = instead of == inside the if: = assigns a value, == compares.
- Forgetting the colon after if and else, or not indenting the print lines.
Now solve a similar question yourself
A new Python question every time, checked instantly.
