A flowchart is included for every subprogram in this scheme. As an alternative to writing the code for a subprogram, ask students to draw the flowchart from the solution code instead. This is good practice for GCSE examinations that require students to write flowcharts (1CP2, 8525, J277).
The flowchart they draw is unlikely to match exactly. This is a good opportunity to discuss abstraction. The necessary details are the sequence, the flowchart symbol used and how they are connected. Where the symbols are drawn on the page and whether decision point yes/no outcomes go to the left/right/underneath is not important but results in the flowchart looking different visually.
Some of the decision points have been written in a way that exemplifies the selection or iteration statement and condition used. This is to make it easier for a student to match a symbol to a line of code. See the example of the while loop below.
attempts = 0
valid_input = False
while not valid_input and attempts < 3:
number = input(“Enter PIN: “)
# Check if PIN matches
if number == pin:
valid_input = True
attempts = attempts + 1
# Return whether PIN is accepted or not
if attempts < 3: