Student Class

You are tasked with creating a Python class that models a Student with the attributes: name, and a list of scores for different subjects. This class should include methods to add a score, calculate the average score, and determine the grade based on the average.
The class should work as follows:
  • The Student class should be initialized with name (string). It should also have a scores attribute which is a list that stores the scores for different subjects.
  • The Student class should have a method add_score(self, score) that accepts a score (float) and adds it to the scores list.
  • The Student class should have a method average(self) that calculates and returns the average score of the student.
  • The Student class should have a method grade(self) that calculates the grade based on the average score and returns it.
Note: For the purposes of this exercise, you may assume that the grading system is as follows:
90 - 100
80 - 90 (90 not inclusive)
70 - 80 (80 not inclusive)
60 - 70 (70 not inclusive)
0 - 60 (60 not inclusive)
The program should execute all the commands properly and return the correct values.
student = Student('Alice'); student.add_score(89.5); student.add_score(78.3); student.add_score(92.4); print(student.average()); print(student.grade()); print(
86.733333 B Alice


Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue