Python – Making Decisions Lecture 02
Control Structures A program that only has one flow is useful but limited. We can use if statements to make these decisions
If - Syntax if (condition): indented code block
Comparison Operators Equal to Greater than Less than Greater than or equal to Less than or equal to Not equal to == > < >= <= !=
Else- Syntax What if you want something to happen when the if condition is false?
If Else - Example
Checking for Multiple Conditions We use an elif statement to check multiple conditions.
Elif - Example
Logic Operators Check for multiple conditions in the same keyword. There are only three: and, or, not.
Precedence
You asleep yet?
Logic Example