Tuples and sets · 13 / 16 Exercise Medium

Student ranking

Objective

Create a Python program that sorts some students by grade using a list of tuples.

Instructions

  • Read the data of 4 students. For each one, read their name and then their grade (integer), on two lines.
  • Store each student as a tuple (grade, name) in a list.
  • Sort the list from highest to lowest (sort(reverse=True)).
  • Show one line per student with the format name: grade.
  • The students' grades will always be different.
Input
ana
7
luis
9
eva
5
marta
8
Output
luis: 9
marta: 8
ana: 7
eva: 5

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise