Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grades = {}
- classes = []
- numclasses = int(input("How many classes do you have? "))
- for i in range(1, numclasses + 1):
- name = input("What is the name of class " + str(i) + "?")
- classes.append(name)
- def calc(classname, grade):
- grades[classname] = grade
- return grades
- for i in range(0, numclasses):
- percentgrade = float(input("What is your percent grade in " + classes[i] + "? "))
- while percentgrade:
- if percentgrade > 100:
- print("Grade cannot be higher than 100.")
- percentgrade = float(input("What is your percent grade in " + classes[i] + "? "))
- elif percentgrade < 0:
- print("Grade cannot be less than 0.")
- percentgrade = float(input("What is your percent grade in " + classes[i] + "? "))
- else:
- calc(classes[i], percentgrade)
- break
- total = 0
- for i in classes:
- total = total + grades[i]
- avg = total / numclasses
- print("Your average is " + str(avg) + " .")
- if avg < 65:
- print("Your GPA is 0.0")
- if 65 <= avg < 67:
- print("Your GPA is 1.0")
- if 67 <= avg < 70:
- print("Your GPA is 1.3")
- if 70 <= avg < 73:
- print("Your GPA is 1.7")
- if 73 <= avg < 77:
- print("Your GPA is 2.0")
- if 77 <= avg < 80:
- print("Your GPA is 2.3")
- if 80 <= avg < 83:
- print("Your GPA is 2.7")
- if 83 <= avg < 87:
- print("Your GPA is 3.0")
- if 87 <= avg < 90:
- print("Your GPA is 3.3")
- if 90 <= avg < 93:
- print("Your GPA is 3.7")
- if 93 <= avg <= 100:
- print("Your GPA is 4.0")
- #Determines which GPA score the raw score should correspond to
- #Code debugged by Arafat
Add Comment
Please, Sign In to add comment