Address the FIXME comments. Move the respective code from the while-loop to the created function. The add_grade function has already been created.# FIXME: Create add_grade functiondef add_grade(student_grades):print('Entering grade. \n')name, grade = input(grade_prompt).split()student_grades[name] = grade# FIXME: Create delete_name function# FIXME: Create print_grades functionstudent_grades = {} # Create an empty dictgrade_prompt = "Enter name and grade (Ex. 'Bob A+'):\n"delete_prompt = "Enter name to delete:\n"menu_prompt = ("1. Add/modify student grade\n""2. Delete student grade\n""3. Print student grades\n""4. Quit\n\n")command = input(menu_prompt).lower().strip()while command != '4': # Exit when user enters '4'if command == '1':add_grade(student_grades)elif command == '2':# FIXME: Only call delete_name() hereprint('Deleting grade.\n')name = input(delete_prompt)del student_grades[name]elif command == '3':# FIXME: Only call print_grades() hereprint('Printing grades.\n') for name, grade in student_grades.items(): print(name, 'has a', grade) else: print('Unrecognized command.\n') command = input().lower().strip()

Respuesta :

Answer:

The Python code is given below with appropriate comments

Explanation:

# FIXME: Create add_grade function

def add_grade(student_grades):

print('Entering grade. \n')

name, grade = input(grade_prompt).split()

student_grades[name] = grade

# FIXME: Create delete_name function

def delete_name(student_grades):

print('Deleting grade.\n')

name = input(delete_prompt)

del student_grades[name]

 

# FIXME: Create print_grades function

def print_grades(student_grades):

print('Printing grades.\n')    

for name, grade in student_grades.items():

print(name, 'has a', grade)

 

student_grades = {} # Create an empty dict

grade_prompt = "Enter name and grade (Ex. 'Bob A+'):\n"

delete_prompt = "Enter name to delete:\n"

menu_prompt = ("1. Add/modify student grade\n"

"2. Delete student grade\n"

"3. Print student grades\n"

"4. Quit\n\n")

command = input(menu_prompt).lower().strip()

while command != '4': # Exit when user enters '4'

if command == '1':

add_grade(student_grades)

elif command == '2':

# FIXME: Only call delete_name() here

delete_name(student_grades)

elif command == '3':

# FIXME: Only call print_grades() here

print_grades(student_grades)

else:

print('Unrecognized command.\n')

command = input().lower().strip()