Operators in Python
Today we learn how Python performs calculations and comparisons
Instructor: Captain Najib Hussein Mohamed
Python Programming @Copyright By Captain Najib Hussein 2026
What is an Operator?
An operator is a symbol used to perform operations
• + Addition
• - Subtraction
• * Multiplication
• / Division
Python Programming @Copyright By Captain Najib Hussein 2026
Arithmetic Operators
x = 10
y=5
print(x + y) # 15
print(x - y) # 5
print(x * y) # 50
print(x / y) # 2.0
Basic math operations in Python
Python Programming @Copyright By Captain Najib Hussein 2026
More Math Operators
% Modulus ** Power // Floor
Remainder Exponent Division
10 % 3 = 1 10 ** 2 = 100 10 // 3 = 3
Python Programming @Copyright By Captain Najib Hussein 2026
Comparison Operators
x = 10
y=5
print(x == y) # False
print(x != y) # True
print(x > y) # True
print(x < y) # False
These return True or False
Python Programming @Copyright By Captain Najib Hussein 2026
Logical Operators
and or not
Both must be True At least one must be True Flips the value
True and False = False True or False = True not True = False
Python Programming @Copyright By Captain Najib Hussein 2026
Real Example
age = 18
print(age >= 18)
Output: True
Checks if person is old enough
Python Programming @Copyright By Captain Najib Hussein 2026
Practice 🔥
a=8
b=2
print(a + b) # ?
print(a * b) # ?
print(a / b) # ?
Python Programming @Copyright By Captain Najib Hussein 2026
Mini Task
Create Variables
Make 2 variables
Apply Operators
Use arithmetic, comparison, or logical operators
Run Code
Test your solution
Python Programming @Copyright By Captain Najib Hussein 2026
Python Programming @Copyright By Captain Najib Hussein 2026