CODE PATH
PRO ACCOUNT

Master Code
On The Go

Learn. Practice. Build.

Quest 1 • Lesson 4

⚡ Conditional Statements (if / elif / else)

Conditional statements let your program make decisions. They execute different code based on whether a condition is True or False.

"Without conditionals, every program would run the same way every time. Conditionals add intelligence."
if_demo.py
age = 18
if age >= 18:
    print("You are an adult")

🧠 The `if` Statement

if_else.py
temperature = 30
if temperature > 25:
    print("It's hot outside")
else:
    print("It's cool outside")
elif_demo.py
score = 85
if score >= 90:
    print("Grade: A")
elif score >= 80:
    print("Grade: B")
elif score >= 70:
    print("Grade: C")
else:
    print("Grade: F")

🔁 elif – Multiple Conditions

✨ Challenge: Number Classifier

Write a program that takes a number (store in a variable). Print:

💡 Try changing the value of num to -3, 0, 10 and see the output.

🧪 Live Mental Playground

What would this code print?

x = 7
if x % 2 == 0:
    print("even")
else:
    print("odd")
Reveal answer

Output: odd (because 7 % 2 == 1, so the else block runs)

❤️ Support Free Education

This course is 100% free. If it helps you, consider buying me a coffee.

☕ Buy Me a Coffee

➡️ Ready for more?

Next lesson: Loops (for/while) – repeat actions efficiently.

Continue to Lesson 1.5 →

(Coming soon – check back or buy Pro Pack for instant access)