Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
dictionary solution in Clear category for Ryerson Letter Grade by pokryshkin
# feel free to change table structure in any way
def ryerson_letter_grade(pct: int) -> str:
TABLE = {
90 <= pct : 'A+',
85 <= pct <= 89 : 'A',
80 <= pct <= 84 : 'A-',
77 <= pct <= 79 : 'B+',
73 <= pct <= 76 : 'B',
70 <= pct <= 72 : 'B-',
67 <= pct <= 69 : 'C+',
63 <= pct <= 66 : 'C',
60 <= pct <= 62 : 'C-',
57 <= pct <= 59 : 'D+',
53 <= pct <= 56 : 'D',
50 <= pct <= 52 : 'D-'}
return TABLE.get(True,'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!")
May 10, 2021
Comments: