Beat the Average

Data with PythonEasy+10 XP+10

Beat the Average

A pub quiz league writes down every quiz a team plays: the team name and the points it scored that night.

The organiser wants to praise the teams that usually do better than a typical quiz score.

Task: write teams_above_average(teams, points). Row i of the log is teams[i] with points[i].

  • Work out each team's average points per quiz.
  • Work out the overall average: the mean of every score in points, all teams together.
  • Return the names of the teams whose own average is greater than the overall average, sorted alphabetically.
  • A team whose average is exactly equal to the overall average is not included.
  • If no team qualifies, return an empty list. There is always at least one row.

Examples

teams = ["Owls", "Foxes", "Owls", "Bees", "Foxes", "Owls"]
points = [30, 22, 26, 18, 25, 28]
returns ['Owls']
teams = ["Red", "Blue", "Red", "Blue", "Green"]
points = [10, 14, 12, 16, 20]
returns ['Blue', 'Green']

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run