Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
original table solution in Clear category for Ryerson Letter Grade by Sim0000
# feel free to change table structure in any way
TABLE = '''
A 85-89%
A- 80-84%
B+ 77-79%
B 73-76%
B- 70-72%
C+ 67-69%
C 63-66%
C- 60-62%
D+ 57-59%
D 53-56%
D- 50-52%
'''
def ryerson_letter_grade(pct: int) -> str:
if pct >= 90: return 'A+'
dic = dict(zip(*[iter(TABLE.split())]*2))
for grade in dic:
lower, upper = map(int, dic[grade][:-1].split('-'))
if lower <= pct <= upper: return grade
return 'F'
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!")
Oct. 13, 2018
Comments: