Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Python Operator Precedence?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___((6 + 3) - (6 + 3))3Order
Put the learning moves in the order that makes the concept easiest to apply.
Operator precedence describes the order in which operations are performed.
Left-to-Right Evaluation
Operator Precedence
Operator Precedence
Operator precedence describes the order in which operations are performed.
Example
print((6 + 3) - (6 + 3))*Precedence Order
The precedence order is described in the table below, starting with the highest precedence at the top:
| Operator | Description |
|---|---|
| () | Parentheses |
| ** | Exponentiation |
| +x -x ~x | Unary plus, unary minus, and bitwise NOT |
| * / // % | Multiplication, division, floor division, and modulus |
| + - | Addition and subtraction |
| << >> | Bitwise left and right shifts |
| & | Bitwise AND |
| ^ | Bitwise XOR |
| Bitwise OR | |
| == != > >= < <= is is not in not in | Comparisons, identity, and membership operators |
| not | Logical NOT |
| and | AND |
| or | OR |
Left-to-Right Evaluation
If two operators have the same precedence, the expression is evaluated from left to right.
+