Tutorial 4/15 Making Decisions

Python: Booleans

Master the logic of True and False - the foundation of all computer logic.

The Hook

A Boolean is like a Light Switch.

It can only be in one of two states: True (On) or False (Off). Computers use these two values for every single decision they make.

True
False

Logic & Comparisons

Python evaluates questions like "Is 10 bigger than 5?" into a Boolean.

is_sunny = True
# Note the capital T
game_over = 10 > 5
# 10 > 5 is True
is_winner = 10 == 100
# 10 == 100 is False (== means 'equal to')
Logic Hub

Predict

What exactly will this logic print?

score = 100
print(score > 200)

Live Python Lab

Comparison Operators.

> SYSTEM READY_
> _
BRONZE

🥉 Make it True

Change the Operator (>) to make the output True.

> _
SILVER

🥈 Fix the Booleans

Fix the case-sensitivity and assignment errors. Variables go on the LEFT.

> _
GOLD

🥇 Age Checker

Ask for age, then create a boolean old_enough using age >= 18.

> _