One Test, Up Close

Data with PythonMedium+10 XP+10

One Test, Up Close

A school exports its mark book as one long list. Student 0's marks come first, one for each of the num_tests tests, then student 1's marks, and so on. The list always splits evenly into students.

A teacher wants a close look at one test. test says which: 0 is the first test, 1 the second, and so on. A mark of pass_mark or more is a pass.

Task: write test_review(marks, num_tests, test, pass_mark) and return a dict about that one test:

KeyValue
"passed"how many students passed it
"share"the fraction of students who passed it, rounded to 2 decimal places
"best"the highest mark anyone got in it
"spread"the spread of its marks, using NumPy's .std(), rounded to 2 decimal places
"pass_average"the average of the passing marks only, rounded to 2 decimal places, or None if nobody passed

There is always at least one student.

Examples

marks = [72, 88, 91, 58, 77, 84, 95, 81, 79, 64, 70, 68]
num_tests = 3
test = 1
pass_mark = 75
returns {'passed': 3, 'share': 0.75, 'best': 88, 'spread': 6.52, 'pass_average': 82.0}
marks = [72, 88, 91, 58, 77, 84, 95, 81, 79, 64, 70, 68]
num_tests = 3
test = 0
pass_mark = 60
returns {'passed': 3, 'share': 0.75, 'best': 95, 'spread': 14.04, 'pass_average': 77.0}

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