May 2017
Intermediate to advanced
310 pages
8h 5m
English
A Boolean operation returns a value of either True or False. Boolean operations are ordered in priority, so if more than one Boolean operation occurs in an expression, the operation with the highest priority will occur first. The following table outlines the three Boolean operators in descending order of priority:
|
Operator |
Example |
|
not x |
Returns True if x is False; returns False otherwise. |
|
x and y |
Returns True if both x and y are True; returns False otherwise. |
|
x or y |
Returns True if either x or y is True; returns False otherwise. |
Both the and operator and the or operator use "short-circuiting" when evaluating an expression. This means Python will only evaluate an operator if it needs to. For ...