What are Conditionals?
Conditionals let your program make decisions: run one block of code when something is true, and a different block when it’s false. In Python you build conditions using comparison operators (like ==, <, >=) and logical operators (and, or, not), then use them inside if statements (and later in loops).
What you’ll learn here
- Comparison operators — Compare two values and get
TrueorFalse(==,!=,<,>,<=,>=). - Logical operators — Combine conditions with
and,or, andnot. - If statements — Run code only when a condition is true, with
elseandeliffor multiple cases.
Work through these in order: comparisons and logical operators give you the building blocks; if statements are where you use them.
Last updated on