Design a class named Assessment to represent an assessment record. The Assessment class contains the following:
• A private String data field named name that defines the name of an assessment.
• A private List data field named answer_list that defines the list of answer keys of an assessment.
• A constructor that creates an Assessment with the required information
• The accessor and mutator methods for all data fields.
• A __str__ method which returns a nicely formatted string representation of an assessment.
• A calculate_marks method which takes a string data as a parameter, compares the answer keys and returns the total marks gained.
Note - keep a copy of your solution to this task because you will use it in your A1
For example:
Test
Result
lab1 = Assessment('test', 'C,C,D,B,A,B,A,C')
print(lab1)
Answer: (penalty regime: 0%)
1 class Assessment:
2
3 def __init__(self, name, answer_list):
4 self.__name = name
5 self.__answer_list = list(answer_list.split(','))
6
7 def get_name(self):
8 return self.__name
9
10 def setName(self, name):
11 self.__name = name
12
13 def get_answer_list(self):
14 return self.__answer_list
15
16 def setAnswer_List(self):
17 self.__answer_list = answer_list
test: answer: ['C', 'C', 'D', 'B', 'A', 'B', 'A', 'C']