Python Day 2 -- operator, python Operator
I. Operators
1. Arithmetic Operation:
A divided by B a divided by c for division. Number after the decimal point
A // B is used for floor division. Only go to the integer, and remove the number after the decimal point
2. Comparison
3. Value assignment
4. bitwise operations
Ps: Temporarily unavailable
5. logical operations
Note: All data types have boolean values (True/False ). Data with a value of False includes (0, '', None), and all other data is True.
And annotation:
1. in python, and or execute boolean logic computations. They do not return boolean values. Instead, return one of the values for actual comparison.
2. Calculate the value of the expression from left to right in the Boolean context. If all values in the Boolean context are true, and returns the last value.
3. If a Boolean context value is false, and returns the first value
Or annotation:
1. When the or clause is used, the left-to-right calculation is performed in the Boolean context, which is the same as the and clause. However, if either of them is True, or this value is returned immediately
2. If all values are False, or the last False value is returned.
3. Note that or will continue expression calculation in the Boolean context until the first true value is found, and the remaining comparison values will be ignored.
And combined with or:
1. Combined with the previous two syntaxes
2. To enhance program readability, it is best to use it with parentheses, for example:
Ps: Generally, do not write this statement, which is easy to read. But there will be that demand!
6. Member operation
Judge the dictionary key value (in only determines the key value)
Judgment list (same tuples)
Judge string
7. Identity Calculation
8. Operator priority: top-down, from high to low