Answered step by step
Verified Expert Solution
Question
1 Approved Answer
6 . 1 1 LAB: Course gradebook with dict Step 1 : Inspect the Gradebook abstract base class The read - only Gradebook.py file has
LAB: Course gradebook with dict
Step : Inspect the Gradebook abstract base class
The readonly Gradebook.py file has a declaration for the Gradebook abstract base class. Access Gradebook.py by clicking on the orange arrow next to main.py at the top of the coding window.
The Gradebook class stores a collection of entries for a course. Conceptually, a gradebook entry is a assignment name, student ID score triplet. Each assignment name is a string, each student ID is an integer, and each score is a float. A score is entered into the gradebook via the setscore method.
The Gradebook class has six abstract methods that must be implemented in an inheriting class.
Step : Add attributes to CourseGradebook class
The CourseGradebook class inherits from Gradebook and is declared in CourseGradebook.py Inspect each method that must be implemented. Choose one or more attributes to store gradebook data and add the attributes to the CourseGradebook class. Several options exist, so grading does not analyze the choice of attributes.
Step : Implement CourseGradebook's setscore and getscore methods
Implement the setscore method to enter a single entry into the gradebook. setscore has parameters for the assignment name, student ID and score. How the entry is stored depends on the attributes chosen in step
Implement the getscore method to get a single score from the gradebook. getscore has parameters for the assignment name and student ID and returns a float for the corresponding score. None is returned if no such entry exists in the gradebook.
Code in main.py calls testgetscoreandsetscore to test both methods. Run your program in develop mode and ensure that the test passes before proceeding further.
Step : Implement the remaining CourseGradebook methods
Implement the remaining methods according to the specifications below.
getassignmentscores takes a string for the assignment name and returns a dict that maps a student ID to the student's corresponding score for the assignment. An entry exists in the returned dict only if a score has been entered with the setscore method. An empty dict is returned if no such assignment exists in the grade book.
getsortedassignmentnames returns a list with all distinct assignment names, sorted in ascending order.
getsortedstudentiDs returns a list with all distinct student IDs, sorted in ascending order.
getstudentscores gets all scores that exist in the gradebook for the student whose ID equals the method parameter. Scores are returned as a dict that maps an assignment name to the student's corresponding score for that assignment.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started