Operators allow you to perform calculations, compare values, and build logic in the code.
Arithmetic
| Operator | Action | Example |
|---|
+ | Addition | 2 + 3 |
- | Subtraction | 5 - 1 |
* | Multiplication | 4 * 2 |
/ | Division | 6 / 2 |
// | Floor division | 7 // 2 |
% | Modulus | 8 % 3 |
** | Exponentiation | 2 ** 3 |
Comparison
| Operator | Meaning | Example |
|---|
== | Equal to | x == y |
!= | Not equal to | x != y |
< | Less than | x < y |
> | Greater than | x > y |
<= | Less than or equal to | x <= y |
>= | Greater than or equal to | x >= y |
Logical
| Operator | Meaning | Example |
|---|
and | Logical AND | True and False |
or | Logical OR | False or True |
not | Logical NOT | not True |