Structured programming
Lesson details
Learning outcome
I can describe what is meant by a structural approach to programming and explain the benefit of this approach.
Key learning points
- As programs grow in complexity it becomes useful to structure them in a way that is more manageable for the programmer.
- A structured approach to programming uses a module approach where a program is seperated into subroutines.
- A program can be decomposed into smaller subroutines that are easier to solve indepedently.
- The interface determines how data will be passed in and out of the subroutine.
Keywords
Subroutine - a sequence of instructions with an identifiable name that performs a specific task
Interface - describes how a subroutine will interact with the main program
Identifer - the name that a programmer gives to a variable, constant, or subroutine
Parameters - used in a subroutine to allow values to be passed into them
Common misconception
A program must run line by line from top to bottom.
A subrotuine is an 'out of line' block of code, which is typcially written at the top of a program and then called upon within the main program.
Teacher tip
This topic links with the concept of decompostion. Encourage pupils to think in high-level terms about what a program needs to do by using a heirachy diagram to plan the parts of a program rather than just diving in and coding.
Equipment
Pupils will need access to a device that can edit and run Python programs. Examples in this lesson use the RPF Code Editor https://oak.link/python-editor
Licence
Lesson video
Loading...
Prior knowledge starter quiz
6 Questions
Q1.Programming languages are considered to be high or low level. Which of the following languages are high level?
Q2.What Python function is used to display output?
Q3.What operator is used for multiplication in Python?
Q4.What is the value of the variable total once the code has finished executing?
123456total = 0
FOR i = 0 TO 3
FOR j = 0 TO i
total = total + i
NEXT j
NEXT iCode colour
Q5.What data type is used in Python to hold whole numbers?
Q6.Which type of loop is used for condition controlled iteration in Python?
Assessment exit quiz
4 Questions
Q1.The structured approach to programming provides many benefits.
From the list below, select the statements that specify a benefit of using the structured approach.
Q2.Select the statement that is true.
Q3.A student wants a subroutine that will add any two given numbers together and display the answer. Use the lines of code below to construct a display_sum subroutine for them.
Q4.What is num1 in this line of code?
def display_sum (num1, num2):
To help you plan your 10 computer science lesson on: Structured programming, download all teaching resources for free and adapt to suit your pupils' needs...
To help you plan your 10 computer science lesson on: Structured programming, download all teaching resources for free and adapt to suit your pupils' needs.
The starter quiz will activate and check your pupils' prior knowledge, with versions available both with and without answers in PDF format.
We use learning cycles to break down learning into key concepts or ideas linked to the learning outcome. Each learning cycle features explanations with checks for understanding and practice tasks with feedback. All of this is found in our slide decks, ready for you to download and edit. The practice tasks are also available as printable worksheets and some lessons have additional materials with extra material you might need for teaching the lesson.
The assessment exit quiz will test your pupils' understanding of the key learning points.
Our video is a tool for planning, showing how other teachers might teach the lesson, offering helpful tips, modelled explanations and inspiration for your own delivery in the classroom. Plus, you can set it as homework or revision for pupils and keep their learning on track by sharing an online pupil version of this lesson.
Explore more key stage 4 computer science lessons from the Programming: subroutines unit, dive into the full secondary computer science curriculum, or learn more about lesson planning.