bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Python/Foundations
Python•Foundations

Python 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:

OperatorDescription
()Parentheses
**Exponentiation
+x -x ~xUnary 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 inComparisons, identity, and membership operators
notLogical NOT
andAND
orOR

Left-to-Right Evaluation

If two operators have the same precedence, the expression is evaluated from left to right.

+

Previous

Python Bitwise Operators

Next

Python Lists