Day 4 — Boolean & if (Decisions)

Python Starter Club • Programmer’s Picnic • Champak Roy

Yesterday we learned how Python calculates. Today we learn how Python decides.

Calm rule: Python never guesses. It only follows True or False.

Comic Visual memory anchor

🎨 Day 4 Comic — True/False + if

Day 4 Comic: Boolean and if
Comic Visual memory anchor

🎨 Day 4 Comic — True/False + if

Day 4 Comic: Boolean and if
Explanation Read once, then practice

✅ What is Boolean?

A Boolean is a value that is either True or False. There is nothing in between.

print(True)
print(False)

🔍 Comparison Operators (How True/False is created)

Python creates True/False by comparing values.

  • > greater than
  • < less than
  • >= greater or equal
  • <= less or equal
  • == equal to
  • != not equal to
print(5 > 3)     # True
print(5 < 3)     # False
print(5 == 5)    # True
print(5 != 5)    # False

Important: One equals = means “store”. Two equals == means “compare”.

📊 Comparison Operators Table

Operator Meaning Example Result
> Greater than 5 > 3 True
< Less than 5 < 3 False
>= Greater or equal 5 >= 5 True
<= Less or equal 4 <= 3 False
== Equal to 5 == 5 True
!= Not equal 5 != 3 True

🧠 Boolean + Variables (A condition is also an expression)

a = 10
print(a > 5)      # True
print(a == 10)    # True

🚦 Introducing if (Decision time)

if means: “Run this code only when the condition is True.”

age = 18

if age >= 18:
    print("Eligible")

Python checks the condition. If it is True, it runs the indented block. If it is False, it skips the block.

🧱 Indentation matters

Python uses spaces to decide what belongs inside if.

if 5 > 3:
    print("Correct indentation")  # ✅

if 5 > 3:
print("Wrong indentation")        # ❌ IndentationError
📝 Day 4 Task

Ask the user for age. If age is 18 or more, print "Eligible".

Optional challenge: Change the age and observe what happens.

Practice Type and run

✍️ Small practice snippets

1) Compare

print(10 > 50)
print(10 == 10)
print(10 != 10)

2) Simple if

number = int(input("Enter a number: "))

if number > 50:
    print("Big number!")

3) Age check (task)

age = int(input("Enter your age: "))

if age >= 18:
    print("Eligible")

Tip: When you see an if, ask: “What condition becomes True/False?”

Pyodide Run Python in browser

🐍 Python Editor (Run)

First run may take a few seconds. Input will appear as browser prompts.

Pyodide not loaded yet.
Output will appear here…

Note: If the condition is False, the indented block is skipped, but the program continues.

Interactive See True / False live

🔍 Boolean Playground

Enter values for a and b. Python-style comparisons update instantly.

Click Compare to see results.