Ravindra BagaleCourses & study guides

3. Python Basics for Data Work

3.3 if, for and Functions

status = "Delivered"
amount = 1299

if status == "Delivered" and amount >= 1000:
    band = "High value delivered"
elif status == "Cancelled":
    band = "Cancelled"
else:
    band = "Other"
print(band)

def delivery_fee(order_amount: float) -> int:
    """Fictional fee slabs for classroom only."""
    if order_amount >= 499:
        return 0
    if order_amount >= 199:
        return 15
    return 30

print(delivery_fee(250))  # 15

Loop example — Diwali spike check on a tiny list:

daily_orders = [180, 210, 950, 880, 200]  # fictional; day 3–4 = Diwali rush
for i, n in enumerate(daily_orders, start=1):
    tag = "SPIKE" if n > 500 else "normal"
    print(f"Day {i}: {n} orders ({tag})")

Practice task

Write a function is_maharashtra_city(name) that returns True only for the six course cities. Test with "Pune" and "Mumbai".