Practice Python if‑elif‑else statements with beginner-friendly exercises. Strengthen your understanding of conditional logic, syntax, and control flow with hands-on coding problems.
Topic: if-elif-else
Write a program that prints the numbers from 1 to n. - But for multiples of 3, print "Fizz" instead of the number - and for the multiples of 5, print "Buzz". - For numbers which are multiples of both 3 and 5, print "FizzBuzz".
15
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
Write a program to check if a number is positive, negative, or zero.
-5
Negative
Write a program to check if a number is even or odd.
7
Odd
Write a program to find the largest of three numbers.
5
9
2
9
Write a program to assign grades based on the score: - A (90-100) - B (80-89) - C (70-79) - D (60-69) - F (<60)
85
B
Write a program to classify age into: - Child (0-12) - Teenager (13-19) - Adult (20-64) - Senior (65+)
25
Adult
Write a program to describe the temperature: - Hot (>30°C) - Warm (20-30°C) - Cold (<20°C)
25.5
Warm
Write a program to check if a person is eligible to vote (18+ years).
17
Not eligible
Write a program to check the strength of a password: - Weak (length <6) - Medium (6-10 characters) - Strong (>10 characters)
password123
Strong
Write a program to print the day of the week based on a number (1-7).
3
Wednesday
Write a program to calculate the discount on a product: - 10% if price >=1000 - 5% if price >=500 - No discount otherwise
750
712.5
Write a program to check if a character is a vowel or consonant.
E
Vowel
Write a program to check if three given lengths can form a triangle. (Sum of any two sides must be greater than the third)
3
4
5
Valid triangle
Write a program to check if a number is a multiple of five.
25
Multiple of five
Write a program to check if an alphabet is uppercase or lowercase.
H
Uppercase
Write a program that: 1. Takes a numerical score as input (0-100) 2. Prints the grade based on: - A (90-100) - B (80-89) - C (70-79) - D (60-69) - F (<60)
85
Grade: B
Write a program that: 1. Takes a number as input 2. Prints whether the number is: - Positive, negative or zero - Even or odd (only if non-zero)
-7
Negative
Odd
Write a program to check if a year is a leap year or not. A leap year is divisible by 4, but not by 100 unless also divisible by 400.
2020
Leap year
Write a simple calculator program that performs: - Addition (+) - Subtraction (-) - Multiplication (*) - Division (/)
5
2
/
2.5
Write a program to calculate BMI and categorize: - Underweight (<18.5) - Normal (18.5-24.9) - Overweight (25-29.9) - Obese (30+)
1.75
70
Normal
Write a program to check the type of a triangle: - Equilateral (all sides equal) - Isosceles (two sides equal) - Scalene (all sides different)
5
5
5
Equilateral
Write a program to print the number of days in a given month (1-12). Assume February has 28 days (ignore leap years).
4
30
Create a simple login system that: 1. Takes username and password as input 2. Checks: - If username is "admin" and password is "12345", print "Access granted" - If username is correct but password wrong, print "Wrong password" - If username doesn't exist, print "User not found"
admin
12345
Access granted
Write a program that: 1. Takes a year as input 2. Determines if it's a leap year (print "Leap year" or "Not a leap year") - Rules: - Divisible by 4 → leap year - Except if divisible by 100 → not leap year - Unless also divisible by 400 → leap year
2000
Leap year
Create a program that: 1. Takes total purchase amount as input 2. Applies discounts: - 5% if amount ≥ 1000 - 10% if amount ≥ 5000 - 15% if amount ≥ 10000 3. Prints final amount after discount
7500
6750.0
Write a program that: 1. Takes three side lengths (a, b, c) as input 2. Determines if they form: - Equilateral triangle (all sides equal) - Isosceles triangle (exactly two sides equal) - Scalene triangle (no sides equal) - Not a triangle (sum of any two sides ≤ third side)
5
5
8
Isosceles triangle
Tutorials, Roadmaps, Bootcamps & Visualization Projects