Question: Write a pyhton function called problem().Create class inside that functon and return the class. In this function, write a class with the following properties and

Write a pyhton function called problem().Create class inside that functon and return the class.

In this function, write a class with the following properties and return the class. Your function should not take any parameters.

Class properties:

The purpose of the class is to define a list of grades and calculate and hold the basic properties such as minimum, maximum, median and mean grades.

Class name should be Grades.

Class should not take any parameter, however should initialize internal values to 0.0.

Class methods:

add_grade(x) that will add the given grade to the internal list.

remove_grade(x) that will return the grade from the internal list if it exists, if it does not exist, it will just ignore it.

get_min() return the minimum grade.

get_max() return the maximum grade.

get_mean() return the mean(average) grade.

get_median() return the median grade. If the number of grades are even, returns the average of the middle two grades (assuming the grades are sorted).

Class constraints:

inputs :None

Example Doctests:

>>> A = problem3()

>>> ainst = A()

>>> ainst.get_min()

0.0

>>> ainst.get_max()

0.0

>>> ainst.get_mean()

0.0

>>> ainst.get_median()

0.0

>>> ainst.add_grade(3)

>>> ainst.add_grade(5)

>>> ainst.get_min()

3.0

>>> ainst.get_max()

5.0

>>> ainst.get_mean()

4.0

>>> ainst.get_median()

4.0

>>> ainst.add_grade(10)

>>> ainst.get_min()

3.0

>>> ainst.get_max()

10.0

>>> ainst.get_mean()

6.0

>>> ainst.get_median()

5.0

>>> ainst.remove_grade(15)

>>> ainst.remove_grade(10)

>>> ainst.get_min()

3.0

>>> ainst.get_max()

5.0

>>> ainst.get_mean()

>>> ainst.get_median()

4.0

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!