Contents
Operators and Expressions
Operators allow you to perform calculations, compare values, and combine conditions. They are frequently used to calculate metrics and filter records during data analysis.
Arithmetic Operators
revenue = 50000
expenses = 32000
profit = revenue - expenses
total = revenue + expenses
average = revenue / 5
remainder = revenue % 3
print("Profit:", profit)
print("Total:", total)
print("Average:", average)
print("Remainder:", remainder)
Common arithmetic operators include +, -, *, /, //, %, and **.
Comparison Operators
Comparison operators return Boolean values (True or False).
sales = 75000
target = 60000
print(sales > target) # True
print(sales == target) # False
print(sales != target) # True
These comparisons are useful for checking whether sales targets were achieved or identifying values that meet specific criteria.
Logical Operators
The and, or, and not operators combine or reverse conditions.
sales = 75000
customer_rating = 4.6
qualified = sales > 50000 and customer_rating >= 4.0
print(qualified) # True
This example identifies a result that satisfies both conditions. In a data analysis workflow, similar logic can help define qualifying customers, profitable products, or high-performing regions.
Python for Data Science
Vishalini A








