Definition
📌 Operators
Python has the familiar arithmetic and comparison operators, but uses readable English keywords — and, or, not — instead of symbols for logical operations.
Syntax
syntax
a + b a - b a * b a / b a % b a ** b a // b
a == b a != b a > b a < b
a and b a or b not aExample
py
a = 10
b = 3
print("Sum:", a + b)
print("Power:", a ** 2)
print("Floor div:", a // b)
print("Is greater:", a > b)Output
outputSum: 13
Power: 100
Floor div: 3
Is greater: True
Important Points
/always returns afloatin Python 3, even when dividing two integers evenly.//is floor division — it rounds the result down toward negative infinity.- Use
and,or,notinstead of&&,||,!. **is Python's power/exponent operator:2 ** 3is 8.
Common Mistakes
- Using
&&/||like in C/Java — Python doesn't support these symbols for booleans. - Expecting
/to give an integer result — in Python 3 it always returns a float. - Forgetting that
//rounds toward negative infinity, not just toward zero, for negative numbers.
Interview Tip
🎯 Before your interview
Be ready to explain the difference between
/ and // in Python 3 — a common quick interview check.
