result = 10 + 5 * 2
print(result)
Output:
20
Multiplication is performed before addition.
Use parentheses to change the order.
result = (10 + 5) * 2
print(result)
Output:
30
🔹 10. Real-World Example
salary = 60000
bonus = 5000
total_salary = salary + bonus
is_high_salary = total_salary > 50000
print(total_salary)
print(is_high_salary)
Output:
65000
True
🎯 Key Takeaways
✅ Operators perform calculations and comparisons.
✅ Arithmetic operators are used for mathematical operations.
✅ Comparison operators return True or False.
✅ Logical operators help combine multiple conditions.
✅ Membership operators check if a value exists in a sequence.
✅ Identity operators check whether two variables refer to the same object.
Double Tap ❤️ For More