Respuesta :

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))

Explanation:

I hope this helps!

The code practice question illustrates the use of conditional statements.

The execution of a conditional statement depends on its truth value

The program in Python, where comments are used to explain each line is as follows:

#Start by initializing the dictionary

dict = {"a": 4, "b": 3, "c": 2, "d": 1, "f": 0}

#This gets input for grade

grade = input().lower()

#This gets input for the weighted average

weighted = int(input())

#If the weighted average is 1, and the grade is in the dictionary

if weighted == 1 and grade in dictionary:

   #This prints the GPA score

   print("Your GPA score is: "+str(dict[grade] + 1))

#If the weighted average is 0, and the grade is in the dictionary

elif weighted == 0 and grade in dictionary:

   #This prints the GPA score

   print("Your GPA score is : "+str(dict[grade]))

#Otherwise

else:

   #The grade is invalid

   print("Invalid")

Read more about similar programs at:

brainly.com/question/19117781