163k views
14 votes
7.4 code practice question 2 edhesive

1 Answer

9 votes

Answer:

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"

grade = input("Enter your Letter Grade: ")

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

gpa = GPAcalc(grade, weight)

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

Step-by-step explanation:

I hope this helps!

User Covik
by
5.1k points