DeaD_EyE

calculate_grade

Jun 29th, 2020
905
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def calculate_grade(score, maximum=100):
  2.     """
  3.    This function returns the grade of score.
  4.    
  5.    score := score in points
  6.    maximum := maximum possible score
  7.  
  8.    The score are normalized internally to 100.
  9.    """
  10.  
  11.     score /= maximum
  12.     score *= 100
  13.     print(score)
  14.     grades_100 = {
  15.         93: "A", 90: "A-",
  16.         87: "B+", 83: "B", 80: "B-",
  17.         77: "C+", 73: "C", 70: "C-",
  18.         67: "D+", 63: "D", 60: "D-",
  19.         }
  20.     for min_score, grade in grades_100.items():
  21.         if score >= min_score:
  22.             return grade
  23.     else:
  24.         return "F"
RAW Paste Data