Ask Question
12 May, 13:08

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.

+4
Answers (1)
  1. 12 May, 13:46
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers