Ad
Code
Diff
  • def grade_calc(grade):
        grade_range = {"F": range(0, 60), "D": range(60, 70), "C": range(70, 80), "B": range(80, 90), "A": range(90, 101)}
        
        grade_finder = [key for key in grade_range.keys() if int(grade) in grade_range[key] and grade >= 0 and grade <= 100]
        
        return grade_finder[0] if grade_finder else "Not a grade"
    • #grade_calc = lambda s: 'FDCBAA'[max(5, int(s//10)) - 5] if 0 <= s <= 100 else 'Not a grade'
    • grade_calc = lambda s: 'FFFFFFDCBAA'[int(s//10)] if 0 <= s <= 100 else 'Not a grade'
    • def grade_calc(grade):
    • grade_range = {"F": range(0, 60), "D": range(60, 70), "C": range(70, 80), "B": range(80, 90), "A": range(90, 101)}
    • grade_finder = [key for key in grade_range.keys() if int(grade) in grade_range[key] and grade >= 0 and grade <= 100]
    • return grade_finder[0] if grade_finder else "Not a grade"