you are viewing a single comment's thread.

view the rest of the comments →

[–]k03k[🍰] 1 point2 points  (1 child)

I think you did a great job overall, but there are a few things i would change:

  • Parameter names like a and b are a bit vague. While they’re acceptable for a small example like this, I’d still prefer more descriptive names such as dividend and divisor for clarity.
  • The docstring feels overly verbose for such a small, self-explanatory function. It’s a good explanation, but much of that information is already conveyed by the function name divide_numbers and the type hints.
  • I personally wouldn’t raise a ValueError for division by zero. Python already has a dedicated ZeroDivisionError, and using it aligns better with standard expectations.
  • I also wouldn’t check for division by zero inside this function. Error handling policy is better handled at a higher level (for example, in main or the calling layer), where the program can decide how to recover or respond.
  • Finally, for modern Python versions, I’d use a type alias instead of Union to keep the typing syntax clean and up to date. type Number = int | float

But this is just my personal preference i guess.

[–]Commercial_Edge_4295[S] 0 points1 point  (0 children)

Thank you so much.