iNTERFACEWARE Products Manual > Learning Center > Learning Python > Conditional Statements and Loops > Boolean Operators |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
If you need to evaluate more than one condition to determine whether to execute a block of code, you can use Boolean operators to specify multiple conditions. The most commonly used Boolean operators are and, or and not. The and operator specifies that a condition is true only if both of its subconditions are true. For instance:
The or operator specifies that a condition is true if either of its subconditions is true:
The not operator specifies that a condition is true if its subcondition is false:
You can combine Boolean operators to specify more than two subconditions:
If and, or and not operators are contained in a single condition, Python evaluates them in the following order:
To force a subcondition to be evaluated first, enclose it in parentheses:
|