1. Arithmetic Operation:
2. Comparison operation:
3. Assignment Operation:
4, bit operation:
Note: ~ Example: 6 Explanation: Multiply the binary number +1 by-1, i.e. ~x =-(X+1),-(101 + 1) = 110
A bitwise reversal can only be used in front of a number. So writing 3+~5 can get the result-3, it's wrong to write a.
5. Logical Operation:
and annotations:
- In Python, and and or to perform Boolean logic calculations, as you would expect, but they do not return Boolean values, but instead return one of the values they actually compare.
- The value of a left-to-right calculus expression in a Boolean context, and returns the last value if all the values in the Boolean context are true.
- If a value in the Boolean context is False, and returns the first false value
or annotations:
- When using or , the left-to-right calculus is evaluated in a Boolean context, just like and. If a value is true,or returns the value immediately
- If all values are false,or returns the last False value
- Note that or in a Boolean context, the expression calculus continues until the first true value is found, and then the remaining comparison values are ignored
And-or used in combination:
- Combining the two preceding grammars, reasoning can be.
- To enhance the readability of the program, it is best to be associated with parentheses, for example:
(1 and ' X ') or ' Y '
6. Member Arithmetic:
7. Identity operations
8. Operator Precedence: top-down, high-to-low priority
python--operator