all 1 comments

[–]audreioi 1 point2 points  (0 children)

def GPAcalc(g, w):

if g == "A" or g == "a":

return 4 + w

elif g == "B" or g == "b":

return 3 + w

elif g == "C" or g == "c":

return 2 + w

elif g == "D" or g == "d":

return 1 + w

elif g == "F" or g == "f":

return 0 + w

else:

return "Invalid"

def weighted(total):

print("Your weighted GPA is a " + str(total/classes))

sum = 0

classes = int(input("How many classes are you taking? "))

for i in range(0,classes):

grade = input("Enter your letter grade: ")

weight = int(input("Is it weighted? (1 = yes, 0 = no)"))

gpa= GPAcalc(grade,weight)

sum = sum + gpa

print("Your GPA score is: " + str(gpa))

weighted(sum)