Skip to the workspace
Pebellslearn by building

Python syntax & reference

Find the form you need, compare how it behaves, and open the complete explanation when you need more depth.

Python 3.10+ syntax; individual entries identify newer features. Browser exercises use the configured Python runner.

2 matching syntax entries

Truth and fallback values

Learn in depth →

Conditions test truthiness; and/or return operands, while not returns a boolean.

value or fallback; a and b; not value

Example

print(bool([]), bool("0"))
print(0 or 10, "" or "guest")

Result

False True
10 guest

Watch for: A fallback using or replaces every falsy value, including zero. Use an explicit None check when zero is valid.

Practise this topic →

Branching and match

Learn in depth →

if/elif selects the first true branch; match checks a subject against patterns.

if condition: ...
elif condition: ...
else: ...

Example

score = 82
if score >= 80:
    print("distinction")
elif score >= 50:
    print("pass")
else:
    print("retry")

Result

distinction

Watch for: Order specific conditions before broader ones. A bare name in a match pattern captures a value rather than comparing an existing variable.

Practise this topic →
Complete explanation index (91 lessons indexed)

Conditionals

Technical sources and review date

Original Pebells examples. Reviewed 2026-10-28.

Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.