Operators¶
Arithmetic¶
| Operator | Description | Example | Result |
|---|---|---|---|
+ |
Addition / string concat | 3 + 2 |
5 |
- |
Subtraction / unary negation | 10 - 4 |
6 |
* |
Multiplication / string repeat | "ab" * 3 |
"ababab" |
/ |
Division (always float) | 7 / 2 |
3.5 |
// |
Integer (floor) division | 7 // 2 |
3 |
% |
Modulo | 10 % 3 |
1 |
** |
Exponentiation (right-associative) | 2 ** 8 |
256 |
String operations¶
+ concatenates two strings:
* repeats a string:
Comparison¶
| Operator | Description |
|---|---|
== |
Equal |
!= |
Not equal |
< |
Less than |
> |
Greater than |
<= |
Less than or equal |
>= |
Greater than or equal |
Comparison operators return true or false.
Logical¶
| Operator | Description |
|---|---|
and |
True if both operands are true |
or |
True if at least one operand is true |
not |
Negates a boolean |
Operator precedence¶
From highest to lowest:
Use parentheses to override precedence: