Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

For the data of Exercise 12.3, estimate a2.

Answered: 1 week ago