Guest User

Untitled

a guest
Feb 25th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. grades = {}
  2. classes = []
  3. numclasses = int(input("How many classes do you have? "))
  4. for i in range(1, numclasses + 1):
  5. name = input("What is the name of class " + str(i) + "?")
  6. classes.append(name)
  7.  
  8. def calc(classname, grade):
  9. grades[classname] = grade
  10. return grades
  11.  
  12.  
  13. for i in range(0, numclasses):
  14. percentgrade = float(input("What is your percent grade in " + classes[i] + "? "))
  15. while percentgrade:
  16. if percentgrade > 100:
  17. print("Grade cannot be higher than 100.")
  18. percentgrade = float(input("What is your percent grade in " + classes[i] + "? "))
  19. elif percentgrade < 0:
  20. print("Grade cannot be less than 0.")
  21. percentgrade = float(input("What is your percent grade in " + classes[i] + "? "))
  22. else:
  23. calc(classes[i], percentgrade)
  24. break
  25. total = 0
  26. for i in classes:
  27. total = total + grades[i]
  28.  
  29. avg = total / numclasses
  30. print("Your average is " + str(avg) + " .")
  31. if avg < 65:
  32. print("Your GPA is 0.0")
  33. if 65 <= avg < 67:
  34. print("Your GPA is 1.0")
  35. if 67 <= avg < 70:
  36. print("Your GPA is 1.3")
  37. if 70 <= avg < 73:
  38. print("Your GPA is 1.7")
  39. if 73 <= avg < 77:
  40. print("Your GPA is 2.0")
  41. if 77 <= avg < 80:
  42. print("Your GPA is 2.3")
  43. if 80 <= avg < 83:
  44. print("Your GPA is 2.7")
  45. if 83 <= avg < 87:
  46. print("Your GPA is 3.0")
  47. if 87 <= avg < 90:
  48. print("Your GPA is 3.3")
  49. if 90 <= avg < 93:
  50. print("Your GPA is 3.7")
  51. if 93 <= avg <= 100:
  52. print("Your GPA is 4.0")
  53. #Determines which GPA score the raw score should correspond to
  54.  
  55. #Code debugged by Arafat
Add Comment
Please, Sign In to add comment