Search a Sorted List with Bisect
Talk it through out loud with your AI coach.
The problem
- medium
- Pro
You need to turn exam scores into letter grades, where 90 and above is an A, 80 and above a B, 70 and above a C, 60 and above a D, and anything lower an F. Explain how Python's bisect module could do this with a sorted list of the boundaries, and what you must get right for a score of exactly 70.
What a strong answer covers
- What bisect searches for and what it returns.
- Turning a position among sorted boundaries into a grade.
- Why the choice between the two bisect variants matters at the edges.
- The cost of keeping a list sorted as items are added.
Common mistake: Ignoring the exact-boundary case, so a score sitting on a cut-off lands in the grade below.
Knowing this is half of it. Saying it clearly out loud is the part the coach helps you practise.
Practise it out loud