Exercise: Extracting Toppers From a Student Record

Let’s try to extract the students with the highest scores from a collection of student records.

We'll cover the following

Problem statement

You have been provided with different grades lists which are all lists of dictionaries, containing the name of the student and the grade percent that they achieved. Here’s an example list:

grades = [
   {"name": "Mary","percent": 90},
   {"name": "Don","percent": 55},
   {"name": "Bob","percent": 70},
   {"name": "Jim","percent": 85},
   {"name": "Meg","percent": 80},
   {"name": "Jil","percent": 75}
]

Therefore, your task is to write the get_top() function which takes in this grades list and then extracts only the students with percent values greater than or equal to 80%.

You need to use any of the functional programming built-in functions (map, filter, reduce) or list comprehension to complete this task.

Input

grades = [
   {"name": "Mary","percent": 90},
   {"name": "Don","percent": 55},
   {"name": "Bob","percent": 70},
   {"name": "Jim","percent": 85},
   {"name": "Meg","percent": 80},
   {"name": "Jil","percent": 75}
]

Output

['Mary', 'Jim', 'Meg']

Challenge

This problem has been designed for you to practice freely, so try to solve it on your own first. Take some time and think about the different concepts that we’ve explored in the course so far.

If you feel stuck, you can always check out the solution review provided in the next lesson.

Good luck!

Get hands-on with 1400+ tech skills courses.