refund_amount(order) for a returns desk. order has price, days_since_delivery, opened (bool), category. Rules in priority order: electronics opened → 0; any item within 7 days → full price; 8-30 days → 50%; beyond 30 → 0. Return the refund value.refund_amount({'price': 1000, 'days_since_delivery': 5, 'opened': True, 'category': 'clothing'})1000
Within 7 days and not opened-electronics.
refund_amount({'price': 1000, 'days_since_delivery': 5, 'opened': True, 'category': 'electronics'})0
The opened-electronics rule fires first.
Guard clauses in priority order read cleanest.
50% path: price * 0.5.