Conclusion
the most important difference between C and Python operator difference is that between comparison operators and (bitwise) logical operators
C
C++ Operator Precedence - cppreference.com
pay attention to row 8~10, the comparison operators, which have higher precedence than bitwise then logical operators.
Python
6.10. Comparisons
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:
Precedence and Associativity of Operators in Python
it should be noted that for python bitwise operator has higher precedence than comparison op. then logical op.
The operator precedence in Python is listed in the following table. It is in descending order (upper group has higher precedence than the lower ones).
Operators Meaning ()
Parentheses **
Exponent +x
,-x
,~x
Unary plus, Unary minus, Bitwise NOT *
,/
,//
,%
Multiplication, Division, Floor division, Modulus +
,-
Addition, Subtraction <<
,>>
Bitwise shift operators &
Bitwise AND ^
Bitwise XOR |
Bitwise OR ==
,!=
,>
,>=
,<
,<=
,is
,is not
,in
,not in
Comparisons, Identity, Membership operators not
Logical NOT and
Logical AND or
Logical OR