The precedence of the operators
The precedence of the operators is a very important concept in programming in general. In fact, the order in which operators are evaluated in the evaluation of an expression (including the conditions) is very important, both in mathematics and in programming itself.
Applying it to what we have said, comparison operators take precedence over Boolean operators when evaluating a condition.
There are conditions that test what we are saying.
>>> False == False or True True >>> False == (False or True) False >>> (False == False) or True True
In Python, the order of operator evaluation respects that of mathematics.
Tabella della precenza
|∼,+,-||Complement, positive or negative numbers|
|*,/,%,//||Multiplication, division, module and rest|
|+, –||Addition, subtraction|
|>>,<<||Bitwise left and right|
|^, |||Bitwise XOR e OR|
|<=, <, >, >=||Comparison operators|
|=, %=, /=, //=,+=, -=, *=, **=||Assignment operators|
|is, is not||Identity operators|
|in, not in||Membership operators|
|not, or, and||Logic operators|