Write a function that calculates the mean, median, variance, standard deviation, minimum and maximum of of list of items. You can assume the given list is contains only numerical entries, and you may use numpy functions to do this. code example

Example: Write a function that calculates the mean, median, variance, standard deviation, minimum and maximum of of list of items. You can assume the given list is contains only numerical entries, and you may use numpy functions to do this.

def dictionary_of_metrics(items):
my_dict = {
    "mean": round(np.mean(items),2),
    "median": round(np.median(items),2),
    "std": round(np.std(items, ddof= 1),2),
    "var": round(np.var(items, ddof= 1),2),        
    "min": round(np.min(items),2),
    "max": round(np.max(items),2),    
}

return my_dict

Tags:

Misc Example