Menu

Import Mean Median Mode Statisticspy Python 3 Using Python 3 Write Class Called Person Two Q43783237

How do you import Mean, Median, and Mode fromstatistics.py in Python 3?

USING PYTHON 3: Write a class called Person that has two datamembers – the person’s name and age. It should have an init methodthat takes two values and uses them to initialize the datamembers.

Write a separate function (not part of the Person class) calledbasic_stats that takes as a parameter a list of Person objects andreturns a tuple containing the mean, median, and mode ofall the ages. To do this, import thestatistics library and use its built-in mean,median, and mode functions. Your basic_stats function should returnthose three values as a tuple, in the order given above.

This is the code I have written so far:class Person: “”” Contains two data members – the person’s name and age. “”” def __init__(self, name, age): “”” This init method takes two values – name and age – and uses them to initialize the data members. “”” self.name = name self.age = agefrom statistics import mean, median, modedef basic_stats(person_list): “”” This function takes as a parameter a list of Person objects and returns a tuple containing the mean, median, and mode of all the ages. “”” THIS IS WHERE I AM COMPLETELY STUCK!p1 = Person(“Kyoungmin”, 73)p2 = Person(“Mercedes”, 24)p3 = Person(“Avanika”, 48)p4 = Person(“Marta”, 24)person_list = [p1, p2, p3, p4]print(basic_stats(person_list)) # should print a tuple of three values

Expert Answer


Answer to How do you import Mean, Median, and Mode from statistics.py in Python 3? USING PYTHON 3: Write a class called Person tha…

OR