Flowcharting algorithms

User guide

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.

def get_pin(pin):

attempts = 0

valid_input = False

# Validation

while not valid_input and attempts < 3:

number = input("Enter PIN: ")

# Check if PIN matches

if number == pin:

valid_input = True

else:

attempts = attempts + 1

# Return whether PIN is accepted or not

if attempts < 3:

return True

else:

return False

Registered in England and Wales: 10442992

VAT Number: 290 9845 58

Telephone: 01452 947500

Email: admin@craigndave.co.uk

Craig'n'Dave logo

Craig 'n' Dave

Bett Awards 2024 Finalist