MeckeOfficial

score to grade 2

Sep 26th, 2021
796
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. grades = {
  2.         "A" :   [80, "A: Excellent!"],
  3.         "B+":   [75, "B+: Very Good!"],
  4.         "B" :   [70, "B: Good!"],
  5.         "C+":   [65, "C+ Credit!"],
  6.         "C" :   [60, "C: Credit!"],
  7.         "D+":   [55, "D+: Above Average"],
  8.         "D" :   [50, "D: Average"],
  9.         "E" :   [0,  "E: Failed"]
  10.     }
  11.  
  12. while True:
  13.     while True:
  14.         try:
  15.             score = input("Please enter your Score: ")
  16.             score = int(score)
  17.             if score in range(0,100):
  18.                 break
  19.         except:
  20.             print("Please enter a Score between 0 and 100.")
  21.      
  22.     for grade in grades:
  23.         if score >= grades[grade][0]:
  24.             print(grades[grade][1])
  25.             break
  26.  
  27.     next = input("Do u want to compute another grade? Y/N").lower()
  28.     if next == "y":
  29.         continue
  30.     else:
  31.         break
RAW Paste Data