The Python Language Reference, Release 3.9.5 6.8 Shifting operations The shifting operations have lower priority than the arithmetic operations: These operators accept integers as arguments. They shift the first argument to the left or right by the number of bits given by the second argument. A right shift by n bits is defined as floor division by pow(2,n) . A left shift by n bits is defined as multiplication with$_{pow(2,n)}$ . Each of the three bitwise operations has a different priority level: The$_{&}$operator yields the bitwise AND of its arguments, which must be integers. The$_{^}$ operator yields the bitwise XOR (exclusive OR) of its arguments, which must be integers. The$_{|}$ operator yields the bitwise (inclusive) OR of its arguments, which must be integers. Unlike C, all comparison operations in Python have the same priority, which is lower than that of any arithmetic, shifting or bitwise operation. Also unlike C, expressions like$_{a < b < c}$ have the interpretation that is conventional in mathematics: Comparisons yield boolean values:$_{True}$ or$_{False}$. Comparisons can be chained arbitrarily, e.g.,$_{x < y <= z}$ is equivalent to$_{x < y and y <= z}$ , except that$_{y}$ is evaluated only once (but in both cases$_{z}$ is not evaluated at all when$_{x < y}$is found to be false). Formally, if a , b , c , …, y , z are expressions and op1 , op2 , …, opN are comparison operators, then$_{a op1 b op2 c}$ ... y opN z is equivalent to$_{a op1 b and b op2 c and ... y opN z}$ , except that each expression is evaluated at most once. Note that$_{a op1 b op2 c}$ doesn’t imply any kind of comparison between a and c , so that, e.g.,$_{x < y > z}$ is perfectly legal (though perhaps not pretty). Chapter 6. Expressions 76 6.10 Comparisons 6.9 Binary bitwise operations and_expr ::= shift_expr | and_expr "&" shift_expr xor_expr ::= and_expr | xor_expr "^" and_expr or_expr ::= xor_expr | or_expr "|" xor_expr comparison ::= or_expr ( comp_operator or_expr )* comp_operator ::= | "is" ["not"] | ["not"] "in" shift_expr ::= a_expr | shift_expr ("<<" | ">>") a_expr