Operator | Description | Example |
---|---|---|
+ | Addition | 9 + 2 = 11 |
- | Subtraction | 9 - 2 = 7 |
* | Multiplication | 9 * 2 = 18 |
/ | Division | 9 / 2 = 4.5 |
// | Floor Division (Integer Div) | 9 // 2 = 4 |
% | Modulo (Remainder) | 9 % 2 = 1 |
** | Exponent (Power) | 9 ** 2 = 81 |
Operator | Description |
---|---|
** | Exponentiation |
* , / , // , % | Multiplication, Division, Floor Division, Modulo |
+ , - | Addition, Subtraction |
**
).a * b
is evaluated first: 9 * 2 = 18
18 / a
is evaluated next: 18 / 9 = 2
a + b
is evaluated: 9 + 2 = 11
11 - 2 = 9
+
) and multiplication (*
) operators for strings, enabling string concatenation and repetition.-
or /
, cannot be applied to strings.+
), subtraction (-
), multiplication (*
), division (/
), floor division (//
), modulo (%
), and exponentiation (**
).**
) has the highest precedence among arithmetic operators.+
and *
operators can be used with strings, tuples, and lists for concatenation and repetition.