Dennis Sweeney <sweeney.dennis...@gmail.com> added the comment:

Another option would be to use globals:

>>> BREAKPOINTS = [60, 70, 80, 90]
>>> GRADES = "FDCBA"
>>> def grade(score):
...     i = bisect(BREAKPOINTS, score)
...     return GRADES[i]
... 
>>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]
['F', 'A', 'C', 'C', 'B', 'A', 'A']

----------
nosy: +Dennis Sweeney

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46224>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to