Priority of the logical operators NOT, AND, OR in Python

It’s NOT, AND, OR, from highest to lowest according to the documentation on
Operator precedence

Here is the complete precedence table, lowest precedence to highest. A row has the same precedence and chains from left to right

 0. :=
 1. lambda
 2. if – else
 3. or
 4. and
 5. not x
 6. in, not in, is, is not, <, <=, >, >=, !=, ==
 7. |
 8. ^
 9. &
 10. <<, >>
 11. +, -
 12. *, @, /, //, %
 13. +x, -x, ~x
 14. **
 14. await x
 15. x[index], x[index:index], x(arguments...), x.attribute
 16. (expressions...), [expressions...], {key: value...}, {expressions...}

Leave a Comment