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
Studentclass should be initialized withname(string). It should also have ascoresattribute which is a list that stores the scores for different subjects.The
Studentclass should have a methodadd_score(self, score)that accepts a score (float) and adds it to thescoreslist.The
Studentclass should have a methodaverage(self)that calculates and returns the average score of the student.The
Studentclass should have a methodgrade(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:
Score | Grade |
|---|---|
90 - 100 | A |
80 - 90 (90 not inclusive) | B |
70 - 80 (80 not inclusive) | C |
60 - 70 (70 not inclusive) | D |
0 - 60 (60 not inclusive) | F |
The program should execute all the commands properly and return the correct values.
Input | Output |
|---|---|
| 86.733333 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB