Precedence of Python Operators in Python


Precedence of Python Operators




Python operators are evaluated according to a set order or priority:




Description
Operators



1
Exponentiation
**




Ccomplement, unary plus,
~, +, -
2
and minus





Multiplication, division,
*, /, %, //
3
modulo, and floor division




4
addition and subtraction
+ -



5
Right and left bitwise shift
>>, <<



6
Bitwise ‘AND’
&




Regular `OR’ and Bitwise
|, ^
7
exclusive ‘OR’




8
Comparison operators
<= < > >=



9
Equality operators
== !=



10
Assignment operators
=, +=, -=, *-, /=, %= //= **=



11
Identity operators
is, is not



12
Membership operators
in, not in



13
Logical operators
or, and, not




Comments

Post a Comment

If you have any query, please let us know