Home > Article > Backend Development > python core data types numeric types and collections
Operation | Description | Operation | Description |
---|---|---|---|
x + y | Addition | x ** y | Power |
x - y | Subtraction | x % y | Modulo (x mod y) |
x * y | Multiplication | +x | One-yuan addition |
x / y | Division (2.6 omit the decimal part) | -y | Uniary subtraction |
x // y | Truncation and division | x if y else z | Ternary expression |
Operation | Description | Operation | Description | |
---|---|---|---|---|
x left shift y bits | x \ | y | bitwise or | |
x shifts right by y bits | x ^ y | Bitwise exclusive OR | ||
bitwise AND | ~x | bitwise negation |
Numeric-related modules
,random
int() and math.trunc() will omit the decimal part, the round() function can do rounding, math.floor is 2.7 The decimal place will be retained as 0 under 3.0, which has the same effect as int under 3.0
python3.0 no longer supports dictionary size comparison, you can use sorted(dict.items()) instead
Set
Why use a set?
Filter out duplicates
Record visited locationsThe above is the detailed content of python core data types numeric types and collections. For more information, please follow other related articles on the PHP Chinese website!