Question: in python I have added the assesment class below as well as the structure for the function below: You are required to complete the read_assessment_solution

in python I have added the assesment class below as well as the structure for the function below:

in python I have added the assesment class below as well asthe structure for the function below: You are required to complete theread_assessment_solution (filename) function which takes a filename as a parameter, reads a

You are required to complete the read_assessment_solution (filename) function which takes a filename as a parameter, reads a list of answer keys per assessment and returns a list of Assessment objects. If the file doesn't exi you should tell the user that the file cannot be found. Implement this behaviour using exception handling (File NotFoundError). For example, the following code fragment assessment list read_assessment_solution ('solution.txt') for assessment in assessment list: print (assessment) prints: labl: answer: ['c', 'C', 'D', 'B', 'A', 'B', 'A', 'C', 'B'] lab2 : answer: ['B', 'D', 'D', 'B', 'D', 'A', 'B', 'A', 'A'] lab3: answer: ['D', 'D', 'D', 'A', 'C', 'C', 'B', 'B', 'B'] defget aansweran MMM class Assessment: #works def init (self.name, answer_keys): self. name = name self. _answer_list = answer_keys.split(',') #accessor def.get_name(self): return self. name answer_list(self): return self. _answer_list #mutator def set_name(self, name) : self.name = name def calculate_marks(self, data): marks = 0 data_list = data.split(',') for i in range(0, len(self._answer_list)): if data_list[i].strip(). self._answer_list[i].strip(): marks += 1 elif self. _answer_list[i].strip() marks+= 0 else: marks+=0 return marks def stromself): return "{}: answer: {}".format(self._name, str(self._answer_list)) def read_assessment_solution(input_filename): try: except: assessment_list = read_assessment_solution('solution. txt') for assessment in assessment_list: print(assessment)

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!