Band Every Score

Data with PythonMedium+10 XP+10

Band Every Score

A teacher turns test scores into bands for school reports:

ScoreBand
80 or more"A"
60 or more, but under 80"B"
under 60"C"

So 80 is an "A" and 60 is a "B".

Task: write grade_bands(names, scores).

  • names and scores are lists of the same length. scores[i] belongs to names[i].
  • Build a DataFrame with a name column and a score column, then add a band column.
  • Return a dictionary mapping each name to its band, in the original order.

Every name is different, and there is always at least one student.

Examples

names = ["Ana", "Ben", "Cara", "Dev"]
scores = [72, 95, 58, 81]
returns {'Ana': 'B', 'Ben': 'A', 'Cara': 'C', 'Dev': 'A'}
names = ["Eli", "Fay", "Gus"]
scores = [80, 60, 59.5]
returns {'Eli': 'A', 'Fay': 'B', 'Gus': 'C'}

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