Advertisement
biswasrohit20

grade

Mar 24th, 2021
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. grades ={"A+": 4.2, "A": 4.0, "A-": 3.9, "B+": 3.7,"B": 3.2, "B-": 3.0, "C+": 2.8,"C": 2.2, "C-": 2.0, "D+": 1.8,"D":1.2,"F":0}
  2.  
  3. check = True
  4. total_count = 0
  5. total_point = 0
  6. while check:
  7. check2 = True
  8. count = 0
  9. point = 0
  10. while check2:
  11. letter = input("Please enter the grade: ")
  12. if letter == "quit":
  13. check = False
  14. break
  15. if letter == "":
  16. break
  17. if letter in grades:
  18. point += grades[letter]
  19. count += 1
  20. else:
  21. print("Invalid Grade!!!")
  22. if point != 0:
  23. gpa = point/count
  24. print(f'The GPA is {gpa}')
  25. elif point == 0:
  26. print("No GPA calculated")
  27. total_count += count
  28. total_point += point
  29.  
  30. if total_point != 0:
  31. overall_avg = total_point/total_count
  32. print(f'The Overall average is {round(overall_avg,3)}')
  33. else:
  34. print("No Overall average calculated")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement