A menu loop that controls user interaction
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.
Understanding A menu loop that controls user interaction in QCE Digital Solutions Unit 2
What it does: The loop reads a choice and an if statement calls the function for that option, for example view_students() when the choice is 1. The loop must keep running while the choice is NOT q. Using == would skip the loop (or stop it) as soon as the user picks anything other than q. The user needs to see the options before choosing. The menu is shown first, then the choice is read, then the matching function is called. Invalid input should not crash or end the program. The else branch prints an invalid choice message and the loop repeats.
Common mistakes: The loop must keep running until the user picks quit, so the condition should be != "q". With == "q" the loop never starts because choice begins as an empty string. A function is only called when it has brackets. Without them the menu is never shown. It should be show_menu().
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 337–409) and word search (Modules 234–409).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
while choice != "q":Fill in the Blanks
Spot the Error
Student with a class code? Join your class →