Exercise · Tuples and unpacking · lesson 8 of 8
Exercise: best student
Write a function best_student(names, scores) that returns a tuple (name, score) for the student with the highest score. The score of student names[i] is stored in scores[i].
best_student(["ann", "bob", "cid"], [90, 95, 80])→("bob", 95)best_student(["ann", "bob"], [88, 88])→("ann", 88)best_student(["eve"], [0])→("eve", 0)
Constraints: the lists have the same length, from 1 to 5 items; scores are integers from 0 to 100; if several students share the highest score, the function returns the one that comes first in the list.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.