Calculate Average of Three Numbers

  • Share this:

Code introduction


Calculates and returns the average of three given numbers.


Technology Stack : Python built-in type checking

Code Type : Function

Code Difficulty :


                
                    
def aaaa(arg1, arg2, arg3):
    """
    计算三个数的平均值
    """
    if not all(isinstance(arg, (int, float)) for arg in (arg1, arg2, arg3)):
        raise ValueError("All arguments must be int or float")
    return (arg1 + arg2 + arg3) / 3