Home >Backend Development >Python Tutorial >Python basics
Mathematical operators
Operators | Operations | Example | evaluates to |
exponent | 2 ** 3 | 8 | |
Get the remainder | 22 % 8 | 6 | |
Quotient rounding | 22 // 8 | 2 | |
Division | 22 / 8 | 2.75 | ##* |
3 * 5 | 15 | - | |
5 - 2 | 3 | + | |
2 + 2 | 4 |
## characters String Operator
Operation | Example | Evaluates to | * |
'a' * 3 | 'aaa' | + | |
'a' + 'b' | 'ab' |
3 basic data types and their conversions Function
Conversion function | Function return value Type | int |
Integer | float | |
Floating point type | str | |
String |
Other functions
Function return value type | Function | print() |
Text output (to screen) | input() | |
Text input (via keyboard) | len() | |
Get the number of characters in a string | round() | |
Find approximate number | range(start value, end value, Step length) | |
Generate sequence | random.randint(integer, integer) | |
Select a random integer | sys.exit() | |
Terminate/Exit the program | abs() | |
Find the absolute value |
##
The above is the detailed content of Python basics. For more information, please follow other related articles on the PHP Chinese website!