Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Bisect solution in Clear category for Ryerson Letter Grade by Sarina
from bisect import bisect
bounds = [50,53,57,60,63,67,70,73,77,80,85,90]
grades = ['F','D-','D','D+','C-','C','C+','B-','B','B+','A-','A','A+']
def ryerson_letter_grade(pct: int) -> str:
return grades[bisect(bounds, pct)]
if __name__ == '__main__':
print("Example:")
print(ryerson_letter_grade(45))
# These "asserts" are used for self-checking and not for an auto-testing
assert ryerson_letter_grade(45) == "F"
assert ryerson_letter_grade(62) == "C-"
print("Coding complete? Click 'Check' to earn cool rewards!")
May 22, 2020