Computer Science Researcher • Educator • Programming Instructor
Operators are symbols that tell Python to perform an action. They allow you to add numbers, compare values, or make decisions inside your program. This lesson explains arithmetic operators, comparison operators, and simple examples for beginners.
Arithmetic operators are used to perform mathematical calculations.
x = 10
y = 3
print(x + y) # Addition
print(x - y) # Subtraction
print(x * y) # Multiplication
print(x / y) # Division
print(x % y) # Remainder
Output:
13
7
30
3.3333333333333335
1
Python performs each calculation step by step. The last line shows the remainder when 10 is divided by 3, which is 1.
print(2 ** 4) # Exponent (2 to the power of 4)
print(17 // 5) # Floor division (division without decimals)
Output:
16
3
Comparison operators check whether values are equal, greater, or smaller. They always return True or False.
print(10 == 5) # Equal to?
print(10 > 5) # Greater than?
print(10 != 3) # Not equal to?
print(4 <= 4) # Less than or equal to?
print(8 >= 2) # Greater than or equal to?
Output:
False
True
True
True
True
Operators make your programs interactive and powerful. You can calculate totals, compare results, control decisions, and build logic for real applications.
1. What does the + operator do?
Divides numbers2. What is the result of 9 % 4?
13. What does 5 ** 2 mean?
5 × 24. What is the output of 17 // 5?
3.45. What does == check?
If two values are equal6. Which operator gives a True or False result?
*7. What does != mean?
Equal8. What is the output of 10 > 3?
79. Which operator gives the remainder?
+10. What is the output of 4 == 4?
8