INNER CODE UNIT · Python
_round_all
webartifex/intro-to-python · 02_functions/sample_module.py:26
def _round_all(numbers):
"""Internal utility function to round all numbers in a list."""
return [round(n) for n in numbers]
def _scaled_average(numbers, scalar):
"""Internal utility function to calculate scaled averages."""
average = sum(numbers) / len(numbers)
return scalar * average
def average(numbers, *, scalar=1):
"""Calculate the average of all numbers in a list.
Args:
numbers (list of int's/float's): numbers to be averaged;
if non-whole numbers are provided, they are rounded
scalar (float, optional): multiplies the average; defaults to 1