¶ Python Base Commands
|
|
|
|
| Operator |
Operation |
Example |
Evaluates to ... |
| ** |
Exponentiation |
2 ** 3 |
8 |
| % |
Modulus/remainder |
22 % 8 |
6 |
| / |
Division |
22 / 8 |
2.75 |
| * |
Multiplication |
3 * 5 |
15 |
| - |
Subtraction |
5 - 2 |
3 |
| + |
Addition |
2 + 2 |
4 |
The order of operations (also called precedence) of Python math operators is similar to that of mathematics. The ** operator is evaluated first; the *, /, //, and % operators are evaluated next, from left to right; and the + and - operators are evaluated last (also from left to right).
¶ Integer, Floating-Point, and String Data Types
|
|
| Data type |
Examples |
| Integer (int) |
-2, -1, 0, 1, 2, 3, 4, 5 |
| Floating-point number (float) |
-1.25, -1.0, -0.5, 0.0, 0.5, 1.0, 1.25 |
| String (str) |
'a', 'aa', 'aaa', 'Hello!', '11 cats', '5' |
