Operator precedence in Python determines the order in which operators are evaluated in an expression.

When an expression contains multiple operators, Python does not evaluate them from left to right blindly.
Instead, it follows a predefined priority order.


Operator Precedence Order :

PrecedenceOperatorDescription
1()Parentheses
2**Exponentiation
3+x, -x, ~xUnary operators
4*, /, //, %Multiplication, Division
5+, -Addition, Subtraction
6<<, >>Bitwise shifts
7&Bitwise AND
8^Bitwise XOR
9``
10<, <=, >, >=, ==, !=Comparisons
11notLogical NOT
12andLogical AND
13orLogical OR
14=Assignment

Example :
Python
result = 100 - 20 * 3 print(result) #output 40 #explanation First Multiplication , then Subtraction

Python
result = 10 > 5 and 5 < 3 print(result) #output False