Statisticians would like to have a set of functions to compute the mean, median and mode of a list of numbers. The mean is the average of the numbers in the list. The median is the number that would appear at the midpoint of a list if it were sorted. The mode is the number that appears most frequently in the list. Define these functions. Please use the starter code stats.py. Expected output: List: [27, 5, 18, 66, 12, 5, 9] Mode: 5 Median: 12 Mean: 20.285714285714285

Respuesta :

Answer:

Python Programming Language

import statistics

mylist =  [27, 5, 18, 66, 12, 5, 9]

print("Mode: ",statistics.mode(mylist))

print("Median: ",statistics.median(mylist))

print("Mean: ",statistics.mean(mylist))

Explanation:

This line imports stats.py into the program

import statistics

This line defines a list (The example list in the program)

mylist =  [27, 5, 18, 66, 12, 5, 9]

This line uses the defined function to calculate and print the mode

print("Mode: ",statistics.mode(mylist))

This line uses the defined function to calculate and print the median

print("Median: ",statistics.median(mylist))

This line uses the defined function to calculate and print the mean

print("Mean: ",statistics.mean(mylist))

ACCESS MORE
EDU ACCESS