DELAPARRA
Index
Color
NL
Category: Error types

ZeroDivisionError

Explained by Updated

What is ZeroDivisionError?

ZeroDivisionError: The code attempts to divide a number by zero, which is mathematically undefined. A ZeroDivisionError in Python, or DivisionByZeroError in PHP, happens when code divides a number by zero. In JavaScript, dividing by zero gives Infinity or NaN instead, which can quietly spread through later calculations. It usually appears in calculations based on data: an average over an empty list, a percentage of a total that is zero, or a conversion rate on a day without visitors.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about ZeroDivisionError

What should you keep in mind with ZeroDivisionError?

Handle the zero case explicitly, often by returning zero, null or a dash in reports, depending on what makes sense to the reader. Think about it whenever you divide by a count or total that comes from data. Tests with empty data sets catch these bugs early, before a dashboard breaks on the first quiet day after launch.

At a glance

CategoryError types
Explained by
Updated

More Error types terms

All terms starting with Z

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.