USD ($)
$
United States Dollar
Euro Member Countries
India Rupee
د.إ
United Arab Emirates dirham
ر.س
Saudi Arabia Riyal

Operators (Arithmetic, Comparison, Logical)

Lesson 7/35 | Study Time: 40 Min

Operators are the building blocks of any program. They allow you to perform calculations, compare values, and make decisions based on conditions. Python provides a clean and intuitive set of operators that are easy to learn and apply. 

Arithmetic Operators

Arithmetic operators are used to perform basic mathematical operations on numerical values.


Example in code:

Note: / always returns a float. Use // when you need a whole number result.

Comparison Operators

Comparison operators compare two values and always return a Boolean result — either True or False. They are heavily used in conditions and decision-making.


Example in code:


Note: Do not confuse == (comparison) with = (assignment). A common beginner mistake.

Logical Operators

Logical operators are used to combine multiple conditions. They are essential when you need more than one condition to be checked at the same time.


Example in code:


Combining All Three — A Practical Example

Here is how arithmetic, comparison, and logical operators work together in a real scenario:



Sales Campaign

Sales Campaign

We have a sales campaign on our promoted courses and products. You can purchase 1 products at a discounted price up to 15% discount.