Question: def get _ grade _ input ( grade _ dict ) : # TODO: Write a function that asks the user for a letter grade.

def get_grade_input(grade_dict):
# TODO: Write a function that asks the user for a letter grade. If the letter grade is in the grade_dict, return it. Otherwise, ask the user again for a valid letter grade.
grade = input("Enter a grade (A+, A, A-, B+, B, B-, C+, C, C-, D+, D, F): ").upper()
if grade in grade_dict:
return grade
else:
print("Invalid grade. Please enter a valid grade.")
def calculate_gpa(grade_value_list):
# TODO: Write a function that calculates the GPA from a list of GPA values
if not grade_value_list:
return 0.0
total_points = sum(grade_value_list)
return total_points / len(grade_value_list)
def main():
# Dictionary that converts letter values to numeric equivalents
grade_dict ={'A+':4.2,'A':4,'A-':3.7,'B+':3.3,'B':3.0,'B-':2.7,'C+':2.3,'C':2.0,'C-':1.7,'D+':1.3,'D':1.0,'F':0}
# List of all letter grades entered
grade_list =[]
# List of all grade values based on letter grades entered
grade_value_list =[]
# TODO: Write the primary logic of your program here
if __name__=="__main__":
main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!