Answer:
class Roster:
def __init__(self,student):
self.student = student
def findValedictoian(self):
highscore = 0
studentList=[]
bStudent = []
valedictorian =''
for pupil in self.student:
if pupil[1] > highscore:
highscore = pupil[1]
valedictorian = pupil[0]
return valedictorian
student = [('rich', 90), ('Bella', 67),('philip', 56)]
englishClass= Roster(student)
print(englishClass.findValedictoian())
Explanation:
we define the roster class using the class keyword, within the class we have our __init__ constructor and we initialize the variable student.
A class method findValedictoian is defined and it compares the grades of each student and returns the name of the student with the highest grade.
An instance is created for English class and the findValedictorian method is called and the valedictorian is printed to the screen.