Practice Problems Help Session 2 estion 6 create a class named student that has
ID: 3573627 • Letter: P
Question
Practice Problems Help Session 2 estion 6 create a class named student that has public data members grade (string) and scores list of integer values). a constructor that Provide takes a parameter for initializing the grade and initializes the list to an empty list. Provide a public method AddMalue) to add new items to the end of the list. Also provide a public method Highest that returns largest of values inlist or if there are no values in the list, return 00 points out of None 1 class Student 2 def init--(self, grade) self grade grade self scores O def Add(self,value): Cself scores) append(value) 7. def Highest(self) self highest 0 if self scores 0: return None else 12 for score in self.scores: 13. if score self highest self highest score return self highest Detailed test results unavailable. Probably an empty answer, or the question is not set to use the required Adaptive Behaviour Debug: source code from all test runsExplanation / Answer
2)
class Student:
def __init__(self,name):
self.name = name
self.scores=[]
def Add(self,value):
(self.scores).append(value)
def Mean(self):
self.mean=0
if self.scores == []:
return None
else:
for score in self.scores:
self.mean = self.mean+score
return int(self.mean/len(self.scores))
3)
class Student:
def __init__(self,grade):
self.grade = grade
self.scores=[]
def Add(self,value):
(self.scores).append(value)
def Total(self):
self.total=0
if self.scores == []:
return None
else:
for score in self.scores:
self.total = self.total+score
return self.total
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.