Operator Precedence
Operator Precedence
Subscription,
2 x[index], x[index:index] Left to right
slicing
Await
3 await x N/A
expression
Exponentiatio
4 ** Right to left
n
Positive,
5 +x, -x, ~x negative, Right to left
bitwise NOT
Multiplication,
matrix,
6 *, @, /, //, % division, floor Left to right
division,
remainder
Addition and
7 +, – Left to right
subtraction
Comparisons,
in, not in, is, is membership
12 Left to Right
not, <, <=, >, >=, !=, == tests, identity
tests
Conditional
16 if-else Right to left
expression
Lambda
17 lambda N/A
expression
Assignment
expression
18 := Right to left
(walrus
operator)