Detailed Notes: Condi!
onal Statements in Python
For Grade 6 IGCSE Students
What Are Condi!onal Statements?
Condi!onal statements let your program make decisions based on certain
condi!ons. Think of it like this:
Example: If it’s raining, bring an umbrella; else, wear sunglasses.
In Python, we use if , elif (short for “else if”), and else keywords to
create these decision-making rules.
Parts of a Condi!onal Statement
1. The if Statement
Checks a condi!on. If the condi!on is True, the code inside the if
block runs.
Syntax:
if condition:
# code to run if condition is True
Example:
age = 12
if age >= 10:
print("You can join the science club!")
Output: You can join the science club!
Explana!on: Since age is 12 (which is ≥ 10), the condi!on is True, so
https://stackedit.io/app# 06/02/25, 8 50 PM
Page 1 of 5
:
the message prints.
2. The else Statement
Runs code only if the if condi!on is False.
Syntax:
if condition:
# code for True
else:
# code for False
Example:
weather = "sunny"
if weather == "rainy":
print("Take an umbrella!")
else:
print("Wear sunglasses! ")
Output: Wear sunglasses!
Explana!on: Since weather is sunny, the if condi!on fails, so the
else code runs.
3. The elif Statement
Checks mul!ple condi!ons in order. Python will test each elif un!l it
finds one that’s True.
Syntax:
if condition1:
# code 1
elif condition2:
https://stackedit.io/app# 06/02/25, 8 50 PM
Page 2 of 5
:
# code 2
else:
# code for all other cases
Example (Grading System):
marks = 75
if marks >= 90:
print("Grade A")
elif marks >= 70:
print("Grade B") # This runs!
elif marks >= 50:
print("Grade C")
else:
print("Try harder!")
Output: Grade B
Using Condi!ons with Operators
You can use comparison operators ( > , < , == , != , >= , <= ) and logical
operators ( and , or , not ) to build condi!ons.
Example 1: Logical Operator and
num = 15
if num > 10 and num < 20:
print("Number is between 10 and 20!")
Output: Number is between 10 and 20!
Example 2: Logical Operator or
fruit = "apple"
https://stackedit.io/app# 06/02/25, 8 50 PM
Page 3 of 5
:
if fruit == "apple" or fruit == "banana":
print("This is a common fruit!")
Output: This is a common fruit!
Common Mistakes to Avoid
1. Missing Colon : : Always add a colon a#er if , elif , and else .
Wrong: if x == 5
Correct: if x == 5:
2. Incorrect Indenta!on: Python uses indents (4 spaces) to define code
blocks.
Wrong:
if x > 0:
print("Positive") # Not indented!
Correct:
if x > 0:
print("Positive")
3. Unreachable Code: Ensure elif / else are not placed before if .
Real-Life Example: Game Logic
Imagine coding a game where a player earns points:
score = 1200
if score >= 1500:
https://stackedit.io/app# 06/02/25, 8 50 PM
Page 4 of 5
:
print("Level 3 Unlocked! ")
elif score >= 1000:
print("Level 2 Unlocked! ") # This runs!
else:
print("Keep playing! ")
Key Takeaways
1. if checks the first condi!on.
2. elif checks addi!onal condi!ons if the first is False.
3. else handles all other cases.
4. Use operators to build complex condi!ons.
Prac!ce Time!
1. Write a program to check if a number is even or odd.
2. Create a quiz ques!on: If the user types “Python”, print “Correct!”, else
print “Try again”.
https://stackedit.io/app# 06/02/25, 8 50 PM
Page 5 of 5
: