Green light: go. Red light: stop. Today Bittu learns IF this, do that โ the superpower inside every game, app and robot.
1The IF spell
An if checks a truth test. If it's True, the indented lines run. If not โ they're skipped, like a door that stays closed:
๐
Py: Two sacred rules: end the if line with a : colon, and give the inside lines 4 spaces of indent. That's how Python knows what's "inside" the if.
2if / else โ two doors
๐ช else is the other door: what to do when the test is False.
๐ค
Bittu: I always walk through exactly ONE door. Test True โ first door. Test False โ else door. Never both.
3elif โ a ladder of doors
Need more than two choices? elif (else-if) makes a ladder. Bittu goes down the ladder and stops at the FIRST True:
The Grade Machine ๐ โ slide the marks!
marks = 65
โ took the elif marks >= 60 door: Great! ๐
4When Bugly attacks ๐
๐
Bugly: My two favourite traps! Forget the colonโฆ or mess up the spaces. Watch:
๐ฆ
Professor Hoot: SyntaxError = grammar mistake. IndentationError = spacing mistake. Both are fixed in seconds once you can READ them โ that's a real programmer skill.
5Decisions + truth tests together
Combine Day 3 and Day 4 โ the rollercoaster gate, now automated:
6Quick quiz! ๐ง
marks = 80. What prints? if marks >= 75: print("A") elif marks >= 60: print("B") else: print("C")
๐ก 80 passes the FIRST test (>= 75), prints A, and the ladder stops there. elif never even looks.
What is missing? if age >= 10 print("ok")
๐ก Every if / elif / else line must end with a colon. Python is strict about its punctuation!
7Your mission ๐
Mission 1: Ask for a password with input(). If it's your secret word, print "Welcome!", else print "Intruder alert! ๐จ".
Mission 2: Ask for marks and print Topper (90+), Great (60+), Pass (35+) or Try again โ with an elif ladder.
Mission 3: Break your code on purpose: remove a colon, read the error, fix it. Bugly hates this trick.
You finished all 4 free days! ๐
Loops, lists, functions, files, APIs and real AI await in Days 5โ24 โ live classes, recordings, and an instructor who answers your doubts.