1

I'm struggling to understand how Python makes the association between the breakpoints sequence and the grades sequence.

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]])

Result = ['F', 'F', 'A', 'C', 'C', 'B', 'A', 'A']

How does python know that a score below 60 == F, score between 60-70 is D, 70-80 is C etc ?

Adwald
  • 13
  • 2

1 Answers1

0

This answer says it all. It's an advanced concept so it takes some time to wrap your head around it.

Daniel Butler
  • 3,239
  • 2
  • 24
  • 37