The Honour Roll

Data with PythonHard+10 XP+10

The Honour Roll

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.

A student makes the honour roll when both of these are true:

  • their average mark is at least cutoff,
  • none of their marks is below 50.

Task: write honour_roll(marks, num_tests, cutoff) and return the positions of the students on the honour roll, as a plain list, smallest first. Students are counted from 0.

If the marks don't split evenly into rows of num_tests, the export is broken. Return None.

There is always at least one mark, and num_tests is at least 1. Don't round the averages before comparing.

Examples

marks = [72, 88, 91, 58, 77, 84, 95, 81, 79, 64, 70, 68]
num_tests = 3
cutoff = 80
returns [0, 2]
marks = [90, 45, 100, 60, 61, 59]
num_tests = 3
cutoff = 60
returns [1]

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