Operations on Two Arguments

  • Share this:

Code introduction


This function takes two arguments and returns their sum, difference, product, and quotient. If the divisor is zero, it returns an error message.


Technology Stack : Function, nested function, arithmetic operations

Code Type : Function

Code Difficulty : Intermediate


                
                    
def arialize(arg1, arg2):
    def arg1_plus_arg2():
        return arg1 + arg2

    def arg1_minus_arg2():
        return arg1 - arg2

    def arg1_times_arg2():
        return arg1 * arg2

    def arg1_divide_arg2():
        if arg2 != 0:
            return arg1 / arg2
        else:
            return "Error: Division by zero"

    return arg1_plus_arg2(), arg1_minus_arg2(), arg1_times_arg2(), arg1_divide_arg2()