Ask Question

Suppose there is a class Roster. Roster has one variable, roster, which is a List of tuples containing the names of students and their number grades--for example, [ ('Richard', 90), ('Bella', 67), ('Christine', 85), ('Francine', 97) ]. Roster has a function findValedictorian that returns the name of the student with the highest grade. Find the valedictorian of the Roster object englishClass and store it in the variable valedictorian.

+2
Answers (1)
  1. 21 July, 09:06
    0
    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Suppose there is a class Roster. Roster has one variable, roster, which is a List of tuples containing the names of students and their ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers