Python Operator Precedence Table

Python Operator Precedence

Operator Description
lambda Lambda Expression
if - else Conditional Expression
or Boolean OR
and Boolean AND
not x Boolean NOT
in, not in Membership tests
is, is not Identity tests
<, <=, >, >=, !=, == Comparisons
| Bitwise OR
^ Bitwise XOR
& Bitwise AND
<<, >> Shifts
+, - Addition and subtraction
*, /, //, % Multiplication, Division and Remainder
+x, -x Positive, Negative
~x Bitwise NOT
** Exponentiation
x.attribute Attribute reference
x[index] Subscription
x[index:index] Slicing
f(arguments ...) Function call
(expressions, ...) Binding or tuple display
[expressions, ...] List display
{key:datum, ...} Dictionary display
`expressions, ...` String conversion

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>