Problem 123111 · medium · Phase 01 Prerequisites & Setup

Above the Class Average

lists · zip · statistics

You are given names and scores of equal length. Write above_average(names, scores) that returns a new list of the names whose score is strictly greater than the class mean, in the original order. Return an empty list when there are no students.

Examples

Input:  names = ["ana", "bo", "cy"], scores = [90, 60, 75]
Output: ["ana"]
Explanation: the mean is 75; only ana is strictly above it.

Input:  names = ["ann", "ben"], scores = [50, 50]
Output: []

Constraints

  • len(names) == len(scores)
  • 0 <= len(names) <= 5000

Goals

  • Compute a mean before filtering
  • Combine two parallel lists to produce a filtered result
Starting Python…