Question: Given a partial class definition below: class Gradebook: def __init__(self, course_name, records): Required arguments: course_name: a string that represents the course name records: a
Given a partial class definition below:
class Gradebook: def __init__(self, course_name, records): """ Required arguments: course_name: a string that represents the course name records: a dictionary with each entry representing a student score pair """ self.records = {} self.course_name = course_name self.records.update(records) def remove(self, student): del self.records[student] def __repr__(self): # substitute your code for pass below pass def update(self, student, score): # substitute your code below for pass below pass Complete the definitions for the __repr__(self) and update(self, student, score) methods so that invoking them will generate outputs as follows:
Code cell 1:
gradebook1 = Gradebook('Python Programming', {'Troy': 92, 'Calvin': 95, 'James': 89, 'Charles': 100, 'Bryn': 59, 'Alice': 95}) gradebook1 Output 1:
Troy -> 92 Calvin -> 95 James -> 89 Charles -> 100 Bryn -> 59 Alice -> 95
Code cell 2:
gradebook1.update("Amy", 100) Output 2:
A new record (Amy -> 100) is added!
Code cell 3:
gradebook1.update("Bryn", 62) Output 3:
Bryn's score has been updated from 59 to 62!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
