Operators in Python are symbols or special keywords that perform operations on operands (values or variables). Think of them as the verbs in the Python language that tell the interpreter what kind of action to take.
Here’s a breakdown of the main categories of operators in Python:
1. Arithmetic Operators:
These operators perform mathematical calculations.
| Operator | Name | Example | Result |
+ | Addition | 3 + 5 | 8 |
- | Subtraction | 10 - 4 | 6 |
* | Multiplication | 6 * 7 | 42 |
/ | Division | 15 / 3 | 5.0 |
// | Floor Division | 15 // 3 | 5 |
% | Modulus | 16 % 5 | 1 |
** | Exponentiation | 2 ** 3 | 8 |
/(Division): Always returns a float, even if the result is a whole number.//(Floor Division): Divides and rounds the result down to the nearest whole number (integer).%(Modulus): Returns the remainder of the division.**(Exponentiation): Raises the left operand to the power of the right operand.
2. Comparison Operators:
These operators compare two operands and return a boolean value (True or False).
| Operator | Name | Example | Result |
== | Equal to | 5 == 5 | True |
!= | Not equal to | 5 != 6 | True |
> | Greater than | 8 > 3 | True |
< | Less than | 2 < 7 | True |
>= | Greater than or equal to | 5 >= 5 | True |
<= | Less than or equal to | 4 <= 6 | True |
3. Logical Operators:
These operators are used to combine or modify boolean values.
| Operator | Name | Example | Result |
and | AND | True and False | False (True only if both operands are True) |
or | OR | True or False | True (True if at least one operand is True) |
not | NOT | not True | False (Reverses the boolean value of the operand) |
4. Assignment Operators:
These operators are used to assign values to variables.
| Operator | Name | Example | Equivalent to |
= | Assignment | x = 5 | x = 5 |
+= | Add and assign | x += 3 | x = x + 3 |
-= | Subtract and assign | x -= 2 | x = x - 2 |
*= | Multiply and assign | x *= 4 | x = x * 4 |
/= | Divide and assign | x /= 2 | x = x / 23 |
//= | Floor divide and assign | x //= 3 | x = x // 3 |
%= | Modulus and assign | x %= 5 | x = x % 5 |
**= | Exponentiate and assign | x **= 2 | x = x ** 2 |
5. Identity Operators:
These operators check if two operands refer to the same object in memory.
| Operator | Name | Example | Result |
is | Is | x is y | True if x and y refer to the same object, False otherwise. |
is not | Is not | x is not y | True if x and y do not refer to the same object, False otherwise. |
6. Membership Operators:
These operators check if a value is a member of a sequence (like a string, list, or tuple).
| Operator | Name | Example | Result |
in | In | 'a' in 'apple' | True if 'a' is found in the string 'apple', False otherwise. |
not in | Not in | 'b' not in 'apple' | True if 'b' is not found in the string 'apple', False otherwise. |
7. Bitwise Operators (Less Common for Beginners):
These operators perform operations at the level of individual bits in integers.
| Operator | Name |
& | Bitwise AND |
| ` | ` |
^ | Bitwise XOR |
~ | Bitwise NOT |
<< | Left shift |
>> | Right shift |
You’ll encounter and use these operators frequently as you write Python code. Understanding how they work is fundamental to building more complex logic and performing various operations on data.

Leave a comment