Question
Grading Lab You've been asked to write a program to manage a set of grades for a student. Grades may be added or removed, and
Grading Lab
You've been asked to write a program to manage a set of grades for a student. Grades may be added or removed, and the program must be able to show all the individual grades, along with the total grade, both for all the grades and for all the grades but dropping the lowest grade. The company has done some work on this already. They've created a module named GradingInterface.py and a module named GradingData.py. Their programmer did what they could, but neither module is complete. You must finish both.
Grading Data
The GradingData.py module has funtions defined that are the way that the GradingInterface.py module interacts with the data. You may define other functions to be used from withing GradingData.py, but you may not define other functions to be used from GradingInterface.py. GradingData.py should do no interaction with the user (no calls to input or print or string.format or Calico Graphics, etc). Grading Interface This module interacts with the user, getting user input and showing data to the user. That's the only thing this module should do! To actually work with the data, the module must call the functions from GradingData.py. The only functions in GradingData.py that this module may call are the ones that were already in GradingData.py. You may not call any functions that you added to GradingData.py.
Why The Restrictions?
This is a software design technique called Model-View-Controller (MVC). You'll learn more about it if you continue on with more computer science courses. MVC requires a little more design work up front, but creates programs that are more flexible in the long run. In the case of this lab, the design work has already been done for you, you just need to implement the functions.
I need to fill in the missing code for a grading interface
# Create the data structure used to store grading data. # # If you need other data that is available to all functions, you # may define it global here. You will be able to read that data # in other functions, but if you want to change the data in those # functions you'll need to define it global there, too. #
def create (): global grading_data
# # Add another grade # # Grades should be an integer in the range 0 to 100 (inclusive) # if it is not, do not add it to the grading list #
def add_grade (grade): global grading_data
# # Remove a grade. Remove only the first instance of that grade # you find. # # Return True if you removed a grade, False if the grade you were # supposed to remove was not found #
def remove_grade (grade): global grading_data
# # Return an average of grades # # The drop_lowest parameter is True if the lowest grade should not # be counted in the grade calculations. If the lowest grade appears # more than once, only drop one of them. # # Should return 0 if no grades have been entered! #
def get_final_grade (drop_lowest): return 0
# # Get a list of grades. Do not return the list you are using to store # the grades, make a copy # # The drop_lowest parameter is true if the lowest grade should not be # included in the list that is returned #
def get_grades (drop_lowest): return 0
This is the code for the interface
import GradingData
# # The following functions must all be implemented # by making calls to the GradingData module. You should not be # doing much code here, except as needed to convert data into the # right format. # # Two of the functions are given to you as an example for # how to implement the rest. #
def add_grade (grade): GradingData.add_grade(grade)
def remove_grade (grade): return GradingData.remove_grade(grade)
def get_all_grades (): pass
def get_grades_without_lowest (): pass
def get_final_grade(): pass
def get_final_grade_without_lowest(): pass
# # Everything below this comment already works, and should # not be changed (or probably even looked at...it uses # more advanced techniques than we'll cover in CPSC 100) #
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