Python Basics — Day 3(Operators in Python)
Aspiring Full-Stack Developer | Python · Django · React · SQL | documenting my learning journey
Building skills in Python and full-stack development, with a focus on web apps and system design
Junior developer in training — Python, Django, React — preparing for a career in full-stack engineering
From Python basics to full-stack projects, sharing my progress as I grow into a developer
Future full-stack engineer | Learning in public: Python, APIs, Databases, and Web Development
Day 3 — Operators in Python
01. Arithmetic Operators
Operator Meaning Example Result + Addition 5 + 2 7 - Subtraction 5 - 2 3 * Multiplication 5 * 2 10 / Division (float) 5 / 2 2.5 // Floor division 5 // 2 2 % Modulus (remainder) 5 % 2 1 ** Exponentiation 2 ** 3 8
a = 7
b = 3
print(a + b) # 10
print(a / b) # 2.333...
print(a // b) # 2
print(a % b) # 1
print(a ** b) # 343
02. Comparison Operators
Operator Meaning Example Result == Equal to 5 == 5 True != Not equal to 5 != 3 True > Greater than 5 > 3 True < Less than 5 < 3 False >= Greater or equal 5 >= 5 True <= Less or equal 3 <= 5 True
x = 10
y = 20
print(x == y) # False
print(x != y) # True
print(x < y) # True
03. Logical Operators
Operator Meaning Example Result and Both must be True True and False False or At least one True True or False True not Negation not True False
age = 25
is_student = False
print(age > 18 and is_student) # False (one is False)
print(age > 18 or is_student) # True (one is True)
print(not is_student) # True (False → True)
04. Operator Precedence
Just like in math, multiplication/division has higher priority than addition/subtraction.
Parentheses ( ) override the order.
print(2 + 3 * 4) # 14 (multiplication first)
print((2 + 3) * 4) # 20 (parentheses first)
05. Practice Examples
Example 1: Arithmetic
x = 15
y = 4
print("Quotient:", x // y)
print("Remainder:", x % y)
print("Power:", x ** y)
Example 2: Comparison
temperature = 30
print("Is it hot?", temperature > 25)
print("Is it cold?", temperature < 10)
📝 Example 3: Logical
score = 85
is_pass = score >= 60
is_excellent = score >= 90
print("Pass?", is_pass)
print("Excellent?", is_excellent)
print("Pass and Excellent?", is_pass and is_excellent)