Lesson 5 of 55
PythonBasic Operators
20 minutes
Course progress9%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 5 of 55
Python20 minutes
Keep these ideas in mind as you work through the lesson.
Python provides a rich set of operators for arithmetic, comparison, logical, and assignment operations.
a = 10
b = 3
print('Add:', a + b) # 13
print('Sub:', a - b) # 7
print('Mul:', a * b) # 30
print('Div:', a / b) # 3.333...
print('Floor div:', a // b) # 3
print('Mod:', a % b) # 1
print('Power:', a ** b) # 1000
print('a > b:', a > b) # True
print('a == b:', a == b) # False
print('a > 5 and b < 5:', a > 5 and b < 5) # True
print('a > 5 or b > 5:', a > 5 or b > 5) # True
print('not (a == b):', not (a == b)) # True
These operators let you build expressions that drive control‑flow and calculations.