How to create a function with arbitrary number of parameters and calculates the average in Python

1 Answer

0 votes
def arithmetic_mean(n, *values):
    total = n
    for i in values:
        total += i

    return total / (1.0 + len(values))

print(arithmetic_mean(4, 5, 8, 9, 13))

'''
run:

7.8

'''

 



answered Dec 17, 2017 by avibootz
...