✅ PYTHON OPERATORS – COMPLETE COMPREHENSIVE TABLE
Operator Type Meaning / Name Why / When To Use Example
To add numbers or 5 + 2 → 7, 'a'
+ Arithmetic Addition
concatenate strings + 'b' → 'ab'
To subtract one number
- Arithmetic Subtraction 7-3→4
from another
To multiply numbers or 4 * 2 → 8,
* Arithmetic Multiplication
repeat strings 'a'*3 → 'aaa'
To divide numbers (result
/ Arithmetic Division 10 / 2 → 5.0
is always float)
Divide and round down
// Arithmetic Floor Division 7 // 2 → 3
to nearest whole number
Modulus To find the remainder
% Arithmetic 7%2→1
(Remainder) after division
Exponentiation To raise a number to a
** Arithmetic 2 ** 3 → 8
(Power) power
🟦 ASSIGNMENT OPERATORS
Operator Type Meaning / Name Why / When To Use Example
Assign a value to a
= Assignment Assign value x=5
variable
Add to current value x += 3 → x =
+= Assignment Add and assign
and assign x+3
Subtract and Subtract from value and x -= 2 → x = x-
-= Assignment
assign assign 2
Multiply and Multiply value and x *= 2 → x =
*= Assignment
assign assign x*2
/= Assignment Divide and assign Divide and assign x /= 2 → x =
x/2
Floor divide and
//= Assignment Floor divide and assign x //= 2
assign
Modulus and Get remainder and
%= Assignment x %= 3
assign assign
Exponent and Raise to power and
**= Assignment x **= 2
assign assign
🟦 COMPARISON (RELATIONAL) OPERATORS
Meaning /
Operator Type Why / When To Use Example
Name
To check if two values are the
== Comparison Equal to x == 5
same
To check if two values are
!= Comparison Not equal to x != 3
different
> Comparison Greater than To compare values x>2
< Comparison Less than To compare values x<5
Greater than or Check if left value is greater
>= Comparison x >= 10
equal than or equal to right
Less than or Check if left value is less than or
<= Comparison x <= 8
equal equal to right
🟩 LOGICAL OPERATORS
Meaning /
Operator Type Why / When To Use Example
Name
Combine conditions – both True and False →
and Logical Logical AND
must be True False
or Logical Logical OR Combine conditions – only one True or False →
must be True True
not Logical Logical NOT Reverse the condition not True → False
🟨 IDENTITY OPERATORS
Meaning /
Operator Type Why / When To Use Example
Name
Object identity Check if two variables point to the
is Identity a is b
check same object in memory
Check if variables do not refer to
is not Identity Opposite of is a is not b
the same object
🟨 MEMBERSHIP OPERATORS
Meaning /
Operator Type Why / When To Use Example
Name
Check if Check if a value exists in a 'a' in 'apple' →
in Membership
value exists sequence (list, string, etc.) True
'x' not in
Value Check if a value does not
not in Membership 'banana' →
doesn't exist exist in a sequence
True
🟥 BITWISE OPERATORS (ADVANCED)
Meaning /
Operator Type Why / When To Use (Advanced) Example
Name
Bit-level AND operation (used in low-
& Bitwise AND 5&3→1
level programming)
Bit-level
` ` Bitwise OR
OR
^ Bitwise XOR Bit-level exclusive OR 5^3→6
~ Bitwise NOT Flip all bits (one’s complement) ~5 → -6
Shift bits left (multiply by powers of 5 << 1 →
<< Bitwise Left Shift
2) 10
>> Bitwise Right Shift Shift bits right (divide by powers of 2) 5 >> 1 → 2
✅ QUICK EXAMPLE OF ALL MAIN TYPES TOGETHER:
PYTHON
COPYEDIT
X = 10
Y=5
# ARITHMETIC
PRINT(X + Y)
# ASSIGNMENT
X += 2
# COMPARISON
PRINT(X > Y)
# LOGICAL
PRINT(X > Y AND Y > 0)
# IDENTITY
PRINT(X IS Y)
# MEMBERSHIP
PRINT('A' IN 'APPLE')
# BITWISE (ADVANCED)
PRINT(X & Y)
🎯 SUMMARY: WHY OPERATORS MATTER
Purpose Operators Used
Math calculations Arithmetic
Assign values Assignment
Make decisions Comparison + Logical
Work with collections Membership
Advanced performance Bitwise