Calculate Division with Infinite Result on Zero Denominator

  • Share this:

Code introduction


Calculate the quotient of two numbers, if the second number is 0, return infinity


Technology Stack : Exception handling, division operation

Code Type : Function

Code Difficulty : Intermediate


                
                    
def aordiff(arg1, arg2):
    try:
        return arg1 / arg2
    except ZeroDivisionError:
        return float('inf')