Average
Calculates the average of two or more numbers.
- Use
sum()
to sum all of theargs
provided, divide bylen()
.
def average(*args): return sum(args, 0.0) / len(args) average(*[1, 2, 3]) # 2.0 average(1, 2, 3) # 2.0
Calculates the average of two or more numbers.
sum()
to sum all of the args
provided, divide by len()
.def average(*args): return sum(args, 0.0) / len(args) average(*[1, 2, 3]) # 2.0 average(1, 2, 3) # 2.0
A snippet collection of list helpers and tips for Python 3.6.
Returns the weighted average of two or more numbers.
Calculates the average of a list, after mapping each element to a value using the provided function.
Calculates the greatest common divisor of a list of numbers.