Operators are being used to perform various operations. Some operators work with 2 operands called binary operators and some operators work with only one operand is called unary operators.
| Name | Operator | Example | Use Case |
| Addition Operator | + | a + b | Add two numbers |
| Subtraction Operator | - | a - b | Calculate Subtraction |
| Multiplication Operator | * | a * b | Calculate Multiplication |
| Division Operator | / | x / y | Calculate Division |
| Modulus Operator | % | x % y | Calculate Modulus |
| Exponentiation Operator | ** | a ** b | Calculate x to the power y. |
| Floor division Operator | // | a // b | Calculate Quotient |
| Name | Operator | Example |
|---|---|---|
| Equal Operator | == | a == b |
| Not equal Operator | != | a != b |
| Greater than Operator | > | a > b |
| Less than Operator | < | a < b |
| Greater than or equal to Operator | >= | a >= b |
| Less than or equal to Operator | <= | b <= b |
| Operator | Example | Same As |
|---|---|---|
| = | a = 5 | a = 5 |
| += | a += 3 | a = a + 3 |
| -= | a -= 3 | a = a - 3 |
| *= | a *= 3 | a = a * 3 |
| /= | a /= 3 | a = a / 3 |
| %= | a %= 3 | a = a % 3 |
| //= | a //= 3 | a = a // 3 |
| **= | a **= 3 | a = a ** 3 |
| &= | a &= 3 | a = a & 3 |
| |= | a |= 3 | a = a | 3 |
| ^= | a ^= 3 | a = a ^ 3 |
| >>= | a >>= 3 | a = a >> 3 |
| <<= | a <<= 3 | a = a << 3 |
| Operator | Use |
|---|---|
| and | Logical AND |
| or | Logical OR |
| not | Logical NOT |
| Operator | Use Case | Example |
|---|---|---|
| is | True for the same object | a is b |
| is not | True for different object | a is not b |
| Operator | Example |
|---|---|
| in | a in b |
| not in | a not in b |
| Name | Operator |
|---|---|
| Bitwise AND | & |
| Bitwise OR | | |
| Bitwise XOR | ^ |
| Bitwise NOT | ~ |
| Bitwise Zero fill left shift | << |
| Bitwise Signed right shift | >> |