Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1while choice != "q": | AKeeps the menu repeating until the user types q to quit | |
| 2else: print("Invalid choice") | BThere is no else branch, so an invalid choice is ignored silently. Add else: print("Invalid choice") so the user knows to try again. | |
| 3Each valid menu option calls its own function inside the loop | Cwhile choice != "q": choice = input("Choice: ") | |
| 4The menu must read a new choice on every pass so the user can quit | DShows an invalid choice message when the input matches no menu option, then the menu appears again | |
| 5while choice != "q": show_menu() if choice == "1": view_students() | Eif choice == "1": view_students() | |
| 6while choice != "q": choice = input("Choice: ") if choice == "1": view_students() elif choice == "2": add_student() | FThe choice is never read inside the loop. choice never changes, so the loop never ends and the user cannot quit. Add choice = input(...) after show_menu(). |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
while choice != "q": — A menu loop repeats: show the menu, read a choice, call that option's function, and stop only when the user picks quit. Other input gets an invalid choice message.choice = ""
while choice != "q":
print_menu()choice = input("Choice: ")
while choice != "q":elif choice == "2":
show_students()else:
print("Invalid choice, try again")choice = input("Enter choice: ")
run_option(choice)