Back

Conditionals

Python uses `if`, `elif`, and `else`. Indentation is how Python knows what's inside each block. No curly braces needed.

age = 20

if age < 13:
    print("Child")
elif age < 18:
    print("Teenager")
elif age < 65:
    print("Adult")
else:
    print("Senior")

# Ternary (one-liner)
status = "adult" if age >= 18 else "minor"

Roadmap