Lesson 015

Control Flow: If Statements

Conditions · If / Else · Elif

1:00

How programs make decisions using if, else, and elif — plus comparison operators, logical operators, short-circuit evaluation, and truthy/falsy values.

By the end, you can

  • Explain what an `if` statement does when its condition is True versus False.
  • Write correct Python `if`, `if/else`, and `if/elif/else` structures with proper colon and indentation.
  • Read any comparison expression and state whether it evaluates to True or False.
  • Trace an elif ladder for a given input value and identify which branch runs.
  • Predict the result of an `and` or `or` expression, including where short-circuiting stops evaluation.
  • Classify Python values as truthy or falsy and explain why `if x:` differs from `if x == True:`.
  • Identify and fix the `=` vs `==` pitfall inside a condition.
Up next in Programming Foundations
Questions or feedback?