Briefle words · Code & architecture
Division by zero
Dividing a number by zero, which has no answer and makes most programming languages raise an error.
Say it to an AI
Python helpers avg_rating(reviews) and refund_rate(refunds, orders) for the seller scorecard. Handle the edge cases explicitly, since new sellers have zero reviews and zero orders: return None for no reviews and 0.0 for no orders, never a division by zero.
How an expert would brief the stronger version of “Seller scorecard metrics”.
See it
Try it as a puzzle →Notebook that computes each seller's average rating and refund rate for a marketplace's weekly scorecard.
Why: A's len(reviews) and orders can both be 0, so 'sum(...) / len(reviews)' and 'refunds / orders' raise ZeroDivisionError.
Related words
Room 4 · Errors & edge cases
Learn “Division by zero” in a five-minute lesson