Python
Python copied to clipboard
Add division.py with input validation for zero denominator
Description
This PR adds a new maths/division.py file with a divide_numbers() function that includes explicit input validation for zero denominators. This addresses issue #13845.
Changes
- Created
maths/division.pywithdivide_numbers()function - Added explicit validation for zero denominator with clear error message
- Included comprehensive docstring with examples and doctests
- Followed repository coding standards with type hints
Benefits
- Provides clearer error messages for beginners learning about error handling
- Aligns with educational best practices for the repository
- Makes the function more robust and user-friendly
Testing
The function includes doctests that cover:
- Normal division cases (positive, negative, decimal results)
- Zero numerator case
- Zero denominator error case
Related Issue
Fixes #13845