Standard library · 13 / 17 Exercise Easy

Grade table with bisect

Objective

The bisect module finds positions in sorted lists using binary search. It is ideal for turning a number into a category according to some limits.

Instructions

  • Use the limits [60, 70, 80, 90] and the letters "FDCBA": below 60 is F, 60 to 69 is D, 70 to 79 is C, 80 to 89 is B and 90 or more is A.
  • Read n and then n whole-number scores, one per line.
  • For each score get its position with bisect.bisect_right(limits, score) and use it to choose the letter.
  • Show score: letter for each score.
Input
3
95
72
40
Output
95: A
72: C
40: F

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise