Skip to content

Conversation

@Aravind30648
Copy link

@Aravind30648 Aravind30648 commented Nov 24, 2025

What This PR Does

This PR adds a new file called division.py to the maths folder. The file has a function called divide_numbers() that divides two numbers and prevents errors when someone tries to divide by zero.

What Was Changed

  • Created a new file: maths/division.py
  • Added a function that divides two numbers safely
  • If someone tries to divide by zero, the function gives a clear error message instead of crashing
  • Added examples showing how to use the function
  • Added type information so it's clear what types of numbers the function accepts

Why This Is Important

This solves issue #13845. When beginners learn about math and algorithms, dividing by zero is a common mistake. This function teaches them that you can't divide by zero and gives them a friendly error message explaining why.

  • I'm adding something new
  • This fixes a problem
  • I'm changing test examples
  • I'm updating documentation

Checklist (I have done all of these):

  • I read the CONTRIBUTING.md file and understand the rules
  • This code is my own work - I didn't copy it from anywhere
  • I know the code will be tested automatically
  • This change is only in one file
  • The file is in the right folder (maths folder)
  • The filename is all lowercase with no spaces
  • The function names follow Python rules
  • The function shows what type of input and output it uses
  • The function has examples that actually work
  • If I added a new algorithm, I included a Wikipedia link
  • This PR references issue Add input validation for division by zero in divide_numbers() #13845 which it fixes

Aravind30648 and others added 2 commits November 24, 2025 18:37
…tion (fixes TheAlgorithms#13845)

This module provides a function to perform division with error handling for zero denominator, making it user-friendly for beginners.
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests are failing Do not merge until tests pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant