Question: Write a class Student that represents a student in a course. The class supports nine methods: __init__ () which takes an optional parameter representing the

Write a class Student that represents a student in a course. The class supports nine methods:

__init__() which takes an optional parameter representing the student's name. It sets the student's name to the parameter, using 'Gertrude' as the default if no name is provided. The constructor also creates an empty list inside the object which will be used to hold Score objects.

__repr__() which returns a string "Student(name, hwLst)" where name is the student's name and hwLst is the list of homework scores for the student. You can see several examples below.

__str__() which returns a string "name has homework scores: hwLst" where name is the name of the student and hwLst is the list of homework scores for the student. You can see several examples below.

addScore() which adds a new Score to the homework list for the student. The method takes a parameter representing the value of the new score, creates a new Score object (using the class developed for the first question), and adds the new Score object into the homework list for the student. The method does not return any values.

getMax() which returns the largest Score object stored in the list of homework scores. If the list of homework scores is non-empty, the method must return a Score object. If the list of homework scores is empty, the method returns None (the type, not a string).

getMin() which returns the smallest Score object stored in the list of homework scores. If the list of homework scores is non-empty, the method must return a Score object. If the list of homework scores is empty, the method returns None (the type, not a string).

getTotal() which returns a Score holding the total of all the homework Scores for the student. The method must return a Score object.

__lt__() which returns True if the calling Student has a name that appears in the alphabet before the Student provided as a parameter. If two students have the same name, then the method returns True if the calling Student has a total score that is less than the parameter Student. Otherwise the method returns False. The total score must be computed via a call to the getTotal() method.

__iter__: The iterator will move through the Score objects stored in the homework list starting with the most-recently added Score and moving to the first Score added to the list. If necessary, you will need to write an appropriate iterator class in order to complete the question. Please note that the file you submit must be self-contained. There should be no imports involving other files.

This is the template

Write a class Student that represents a student in a course. The

This is the output in Python. Please use Python

class supports nine methods: __init__() which takes an optional parameter representing the

# Write this class for the assignment # Change the headers as required by the assignment description class Student(object): def __init__(self, name): pass def __repr__(self): pass def __str__(self): pass def addScore(self, points): pass def getMax(self): pass def getMin self): pass def getTotal(self): pass def other): -lt--(self, pass def __iter__(self) pass

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!