Suppose class Student represents information about students in a course. Each st
ID: 3812424 • Letter: S
Question
Suppose class Student represents information about students in a course. Each student has a name and a list of test scores. The Student class should allow the user to view a student's name, view a test score at a given position, view the highest test score, view the average test score, and obtain a string representation of the student's information. When a Student object is created, the user supplies the student's name and the number of test scores. Each score is initially presumed to be 0. Complete the missing codes in the following program. class Student (object) "Represents a student. def init (self name, number) All scores are initially 0. self name name self scores for count in xrange (number) self scores append (0) def getName (self) ''''''Returns the student's name. your code here def setScore (self, i, score) "Resets the ith score, counting from 1. your code here def gets core (self i) Returns the ith score, counting from 1. your code here def get Average (self) "Returns the average scoreExplanation / Answer
def getName(self)
self._name
def setScore(self,i,score):
self._score[i-1]=score
def getScore(self, i):
return self._score[i-1]
def getAverage(self):
lsum = sum(self._score)
avg = lsum/len(self._score)
return avg
def getHighestScore(self):
return max(self._score)
def _str_(self)
return "%s is a %s" % self._name
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.