Question: Python Problem 4- Create a class Population with attributes: - pop(list[Person]) with methods: __init__(people) initialize the Population.pop attribute with people add_person(person) - a method that

Python Problem 4-

Create a class Population with attributes:

- pop(list[Person])

with methods:

__init__(people) initialize the Population.pop attribute with people

add_person(person) - a method that takes a Person and adds them to the population (updating the self.pop attribute)

add_people(people) - a method that takes a list of Person objects and adds them to the population (updating the self.pop attribute)

filter_population(m_or_f, height_min, height_max, weight_min, weight_max)- Where m_or_f is a string = ('male', 'female', 'both'). Each of the parameters should be used to filter the Population.pop down to the relevant Person objects, and return the resulting list of Persons

Population.filter_population(male, 48, 84, 100, 300) would get the Person objects with the following:

Person.sex = male

48 <= Person.height < = 84

100 <= Person.weight <= 300

Population.stats()- This method should return a dictionary containing the mean, median, and standard deviation for each distribution (Age, Height, Weight) for the entire population, females, and males.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!