我正在努力理解 Python 如何在断点序列和等级序列之间建立关联。
def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):
i = bisect.bisect(breakpoints, score)
return grades[i]
print([grade(score) for score in [33, 59, 99, 77, 70, 89, 90, 100]])
结果 = ['F', 'F', 'A', 'C', 'C', 'B', 'A', 'A']
python如何知道低于60的分数== F,60-70之间的分数是D,70-80是C等?