Python operators in software development are special symbols or keywords used to perform operations on values and variables. These operations can be arithmetic, comparisons, logical decisions, bit manipulations, assignments, and more.
Learn how software engineering in Abuja
Python groups operators into seven major categories:
- Arithmetic Operators
- Comparison (Relational) Operators
- Logical Operators
- Assignment Operators
- Bitwise Operators
- Membership Operators
- Identity Operators
Let’s break each one down with simple examples.
1. Arithmetic Operators
Used for mathematical operations.
| Operator | Meaning | Example |
|---|---|---|
+ | Addition | 3 + 2 → 5 |
- | Subtraction | 5 - 1 → 4 |
* | Multiplication | 4 * 3 → 12 |
/ | Division | 10 / 2 → 5.0 |
% | Modulus (remainder) | 10 % 3 → 1 |
** | Exponentiation | 2 ** 3 → 8 |
// | Floor division | 7 // 2 → 3 |
Example:
a = 7
b = 3
print(a + b) # 10
print(a % b) # 1
print(a ** b) # 343
2. Comparison Operators
Used to compare values. They return True or False.
| Operator | Meaning | Example |
|---|---|---|
== | Equal to | 5 == 5 → True |
!= | Not equal | 5 != 3 → True |
> | Greater than | 4 > 2 → True |
< | Less than | 3 < 1 → False |
>= | Greater or equal | 4 >= 4 → True |
<= | Less or equal | 2 <= 3 → True |
Example:
x = 10
y = 20
print(x < y) # True
print(x == y) # False
3. Logical Operators
Used for boolean logic operations.
| Operator | Meaning |
|---|---|
and | True if both conditions are true |
or | True if at least one is true |
not | Negates a boolean |
Example:
x = 5
print(x > 2 and x < 10) # True
print(x < 2 or x == 5) # True
print(not(x == 5)) # False
4. Assignment Operators
Used to assign values and perform compound assignment.
| Operator | Meaning | Example |
|---|---|---|
= | Assign | x = 10 |
+= | Add and assign | x += 3 |
-= | Subtract and assign | x -= 2 |
*= | Multiply and assign | x *= 4 |
/= | Divide and assign | x /= 2 |
%= | Modulus assign | x %= 3 |
**= | Power assign | x **= 2 |
//= | Floor divide assign | x //= 3 |
Example:
x = 10
x += 5 # x = x + 5
print(x) # 15
5. Bitwise Operators
Used to perform operations on binary numbers.
| Operator | Meaning | Example |
|---|---|---|
& | AND | 5 & 3 → 1 |
| ` | ` | OR |
^ | XOR | 5 ^ 3 → 6 |
~ | NOT | ~5 → -6 |
<< | Left shift | 5 << 1 → 10 |
>> | Right shift | 5 >> 1 → 2 |
Example:
a = 5 # 101 in binary
b = 3 # 011 in binary
print(a & b) # 1
print(a | b) # 7
6. Membership Operators
Check if a value exists in a sequence (list, string, tuple).
| Operator | Meaning |
|---|---|
in | True if value is present |
not in | True if value is not present |
Example:
nums = [1, 2, 3, 4]
print(3 in nums) # True
print(5 not in nums) # True
7. Identity Operators
Check if two variables reference the same object in memory.
| Operator | Meaning |
|---|---|
is | True if identical objects |
is not | True if not identical |
Example:
a = [1, 2]
b = a
c = [1, 2]
print(a is b) # True (same object)
print(a is c) # False (same content, different object)
Summary
Python operators allow you to:
- Do math operations
- Compare values
- Combine conditions
- Manipulate bits
- Assign values efficiently
- Test membership and identity
They form the foundation of logical and mathematical operations in Python programming.

Latest tech news and coding tips.