Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
DON’T TOUCH THE TABLE! solution in Clear category for Ryerson Letter Grade by Detka_v_Ogne
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 > 89: return "A+"
elif pct < 50: return "F"
else:
table = ("%" + TABLE).split("%\n")[1:-1]
for grade in table:
letter = grade.split(" ")[0]
procent = int(grade.split(" ")[1][0:2])
if pct >= procent:
return letter
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!")
June 24, 2020