← Lesson
BitWithBite
Python · Quick Reference

Lesson 6 — Conditionals Cheat Sheet

Python
In one line: Every real program needs to make decisions. Conditional statements let your program run different code depending on whether a condition is True or False. Without them, every pro...

Key Ideas

1What Are Conditionals?. Every real program needs to make decisions. Conditional statements let your program run different code depending on whether a condition is True or False. Without them,...
2Indentation — Python's Core Rule. Indentation in Python is not a style choice — it is the syntax. The interpreter uses indentation to determine which statements belong to which block. You must be consi...
3Combining Conditions. Use and, or, and not to build complex multi-part conditions inside an if statement. You already know these operators from Lesson 4 — now they become the backbone of yo...
4Nested Conditionals. You can place an if statement inside another if statement. This is called nesting. It's useful when a second decision only makes sense after a first condition is confi...
5Truthy & Falsy Values. In Python, any value can be used as a condition — not just booleans. Python automatically treats values as True (truthy) or False (falsy). This is one of Python's most...

Code Examples

temperature = 38 # Simple if if temperature > 37: print("You have a fever.") # runs — 38 > 37 is True # if / else age = 16 if age >= 18: print("You can vote.") else: print("Too young to vote.") # runs — 16 >= 18 is False # if /...
if age >= 18: print("adult") # no indent! if score > 50: print("pass") print("well done") # extra indent!
if age >= 18: print("adult") # 4 spaces if score > 50: print("pass") # 4 spaces print("well done") # same level