Python icon indicating copy to clipboard operation
Python copied to clipboard

Add division.py with input validation for zero denominator

Open kelvinwaringa opened this issue 2 months ago • 0 comments

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.py with divide_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

kelvinwaringa avatar Nov 17 '25 15:11 kelvinwaringa