You now know how to flag churned customers with is_churned. How do you currently decide if a customer is enterprise, mid-market, or starter?
Manually. I look at their MRR and make a judgment call based on whether they're above $1,000 or $500. I've been meaning to write that down formally.
Write it down in code. Three tiers map directly to if/elif/else. The first if catches the highest tier. elif catches the middle. else is everything that falls through — no need to write a third comparison:
if mrr >= plan_threshold:
return "enterprise"
elif mrr >= plan_threshold * 0.5:
return "mid-market"
else:
return "starter"What if mrr is exactly plan_threshold * 0.5? Does elif catch that?
Yes — >= is greater than or equal to, so the boundary value triggers the elif branch, not else. The else only fires when all preceding conditions are False. No condition needed in the else line itself. Here's the full function:
def categorize_customer(mrr: float, plan_threshold: float) -> str:
if mrr >= plan_threshold:
result = "enterprise"
elif mrr >= plan_threshold * 0.5:
result = "mid-market"
else:
result = "starter"
print(f"Category: {result}")
return resultSo I can run this on every customer and auto-segment my entire customer base by plan tier. That's my Monday segmentation report done.
Your Monday segmentation report is now a function you call on 500 customers in a loop — which is exactly what Week 2 is about.
I went from "MRR as a variable" to "automated customer segmentation" in five days. That's real leverage.
The key insight: else is a catch-all — it runs only when every condition above it is False. Don't add a condition to else. Conditions belong in if and elif.
Three-tier branching is the foundation of decision logic. Python evaluates conditions top to bottom and executes the first matching branch.
if condition_1: # checked first
...
elif condition_2: # checked only if condition_1 is False
...
else: # runs only if all above are False
...Don't repeat the negative condition in else. elif not (mrr >= threshold) is redundant — else already means "nothing above matched." Redundant conditions make code harder to read.
You now know how to flag churned customers with is_churned. How do you currently decide if a customer is enterprise, mid-market, or starter?
Manually. I look at their MRR and make a judgment call based on whether they're above $1,000 or $500. I've been meaning to write that down formally.
Write it down in code. Three tiers map directly to if/elif/else. The first if catches the highest tier. elif catches the middle. else is everything that falls through — no need to write a third comparison:
if mrr >= plan_threshold:
return "enterprise"
elif mrr >= plan_threshold * 0.5:
return "mid-market"
else:
return "starter"What if mrr is exactly plan_threshold * 0.5? Does elif catch that?
Yes — >= is greater than or equal to, so the boundary value triggers the elif branch, not else. The else only fires when all preceding conditions are False. No condition needed in the else line itself. Here's the full function:
def categorize_customer(mrr: float, plan_threshold: float) -> str:
if mrr >= plan_threshold:
result = "enterprise"
elif mrr >= plan_threshold * 0.5:
result = "mid-market"
else:
result = "starter"
print(f"Category: {result}")
return resultSo I can run this on every customer and auto-segment my entire customer base by plan tier. That's my Monday segmentation report done.
Your Monday segmentation report is now a function you call on 500 customers in a loop — which is exactly what Week 2 is about.
I went from "MRR as a variable" to "automated customer segmentation" in five days. That's real leverage.
The key insight: else is a catch-all — it runs only when every condition above it is False. Don't add a condition to else. Conditions belong in if and elif.
Three-tier branching is the foundation of decision logic. Python evaluates conditions top to bottom and executes the first matching branch.
if condition_1: # checked first
...
elif condition_2: # checked only if condition_1 is False
...
else: # runs only if all above are False
...Don't repeat the negative condition in else. elif not (mrr >= threshold) is redundant — else already means "nothing above matched." Redundant conditions make code harder to read.
Sam segments her 500 customers into enterprise, mid-market, and starter tiers every Monday to decide which accounts get personal attention. Write `categorize_customer(mrr, plan_threshold)` that returns `'enterprise'` if mrr >= plan_threshold, `'mid-market'` if mrr >= plan_threshold * 0.5, and `'starter'` otherwise — for example, `categorize_customer(1200.0, 1000.0)` should return `'enterprise'`.
Tap each step for scaffolded hints.
No blank-editor panic.