Skip to content
← Python for AI/ML · all 50 levels

if / else

Level 12 of 50 · Decisions & loops

Level 12 of 50

if / else

explained with load shedding. Watch the reel, then work through it below: run the code, take the quiz, keep the cheat sheet.

📒 Open the cheat sheet
SanaOh no! The light's gone AGAIN!
TeacherRelax! The UPS just made a decision. And in Python? That's one word: if!
ups.py
light = "off"

if light == "off":
    print("UPS on")
Teacherif checks a condition. True? The indented line runs!
SanaWait, why the colon?
TeacherColon + 4 spaces! That's how Python knows what's inside the if!
ups.py
light = "on"

if light == "off":
    print("UPS on")
else:
    print("UPS off")
TeacherAnd else? That's plan B! Light's back, UPS off!

⏸ Pause & predict: what prints?

chai = 2

if chai > 3:
    print("Too much chai")
else:
    print("One more chai")
Next: elif →← and / or / not

Where this leads

Python is step one. Building AI that ships is the rest.

The diploma takes you from zero to deployed computer vision, LLM and agent projects, with engineers who build them for a living. Already code? The bootcamp does it in three months.