Your question is Walk Through Code Block. Take a moment with it on the right.
Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).
Bell's billing systems team asked candidates to read a short Python helper that turns a raw usage record into a billing-ready object.
def build_usage_record(customer_id, minutes=None, data_mb=None, extras=[]):
extras.append("base_plan")
record = {}
record["customer_id"] = customer_id
record["minutes"] = minutes
record["data_mb"] = data_mb
record["overage"] = minutes > 500
total = 0
for item in extras:
total = total + item.get("cost")
record["extras"] = extras
record["total_extra_cost"] = total
return record
Can you walk me through this block of code, what it does, and what would go wrong the first time it's actually called with real data?