Python icon indicating copy to clipboard operation
Python copied to clipboard

Add division.py with divide_numbers function and zero division valida…

Open Aravind30648 opened this issue 1 month ago • 0 comments

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.

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

Checklist (I have done all of these):

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

Aravind30648 avatar Nov 24 '25 14:11 Aravind30648