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 isF, 60 to 69 isD, 70 to 79 isC, 80 to 89 isBand 90 or more isA. - Read
nand thennwhole-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: letterfor each score.
3
95
72
40
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