Question: Instructions for the code: 1) Modify the add_grade() function so that each grade can have a different weight. The weight will be a floating-point value.

Instructions for the code:

1) Modify the add_grade() function so that each grade can have a different weight. The weight will be a floating-point value.

2) Add a new function called grades_average() to the Student class to compute the average of all the grades for a student (taking into account the weights from part #1 of the assignment). The average should be given as a float between 0.0 and 100.0. For example, if a student got 90/100 on the first test and 20/25 on the second test, and the second test's weight was double the weight of the first test then the average should be 83.33.

The function should return None when the student received no grade yet.

3) Add way to compare two Student objects simply based on their grade average using operators like >=, >, <, <=, != and ==.

For example a Student object with an average of 85.7 will be considered greater than a Student object with an average of 71.3. Two Student objects are considered equal when the grades are equal, i.e. the names of the students are ignored.

See http://thepythonguru.com/python-operator-overloading/ for some information.

Code that I need assitance on:

class Person: # This function is called whenever a new Person object is created. The # self parameter refers to the object itself, i.e. the instance of the # class that is being created. def __init__(self, first, last): self.first = first self.middle = None self.last = last def __str__(self): return self.first + ' ' + self.last def add_middle_name(self, middle): self.middle = middle

class Student(Person): def __init__(self, first, last): super().__init__(first, last) # Call parent's __init__() function self.grades = [] def __str__(self): return Person.__str__(self) + ' ' + str(self.grades) def add_grade(self, grade, max_grade): self.grades.append((grade, max_grade))

# This is to list all the methods in the Student class. See which one(s) of # those you have to implement for part #3 of the assignment... for f in [func for func in dir(Student) if callable(getattr(Student, func))]: print(f)

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!