Year8 Computing Summer Unit5 Final
Year8 Computing Summer Unit5 Final
Unit 5: Programming
Software note: The programming environment is you to choose. Whilst Python has been chosen as the primary language to demonstrate aspects of this unit, you
can use any similar text-based or block-based environment. Where appropriate, you should prepare your own examples in the environment you choose.
Support: Throughout this unit, you can use a variety of ways to support students in coding:
Modelling: demonstrating coding to students (this can be teacher demonstrations, or students supporting each other).
Guided discovery: guide students in step-by-step development – students choose what to explore and follow teacher or peer demonstrations as and when
required.
Parsons type problems: when using Scratch, provide the right blocks to use but not sorted correctly; in text language, provide the correct code in jumbled
order.
Scaled support:
o use (for those needing additional support – use code supplied by teacher)
o modify (for those who are able to code but need some support – modify supplied code, i.e. fix errors, restructure, assemble)
o create (once they have become more confident in coding – create code from ‘blank canvas’).
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5
Understand and use Use the ‘turtle’ library in Understand and use sequence Understand and use Know how to spot and fix bugs
sequence in an algorithm Python to draw regular 2D in an algorithm sequence in an algorithm in algorithms
polygon shapes
Understand the importance Understand and use iteration Understand and use iteration
of precise instructions when (Students at the computer) (repetition) in an algorithm in an algorithm (FOR and
writing code WHILE loops)
(Students at the computer)
Understand and use Understand and use Understand and use sequence Understand and use Understand and use string
sequence in an algorithm selection in algorithms in an algorithm sequence in an algorithm manipulation in algorithms
Understand and use lists in Understand and use selection in Understand and use Understand and use lists in
an algorithm algorithms subprograms in algorithms algorithms
(Students at the computer) (Students at the computer) (Students at the computer)
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 8, Unit 5: Programming, Lesson 1
Understand and use Students will have experience instructions, detail, PD8.1B Understand and use sequence, selection and iteration
sequence in an of writing algorithms in earlier precise, clear,
algorithm years improve/revise,
sequence, algorithm
Understand the
importance of precise
instructions when
writing code
Teaching Summary
Put students into pairs and instruct each pair to sit back to back. Give one member of each pair an activity card from Year 8, Unit 5, Lesson 1, Worksheet 1 and
the other a pen and paper (or mini-whiteboard).
Inform the students with the activity cards that they will take on the role of navigator. They will read out the instructions to their partner who must try to
recreate the monster on their partner’s card using the verbal instructions alone. After a few minutes have passed, stop the students and ask them to swap
drawings (the activity card and their partner’s hand-drawn image). Ask the students to note any similarities / differences between their images.
Pose the question: ‘Why is everyone’s drawing so different to the original?’. Draw out answers such as: ‘Not enough detail in the instructions’ and
‘Instructions need to be more precise’. Ask the students to suggest some ways in which to improve the instructions and list their answers on the
whiteboard / screen.
Set a timer to 15 mins and challenge the students, in their designated pairs, to revise and improve the instructions on the activity cards. Once the time is
up, select pairs at random and ask them to read their instructions. Follow the students’ instructions exactly whilst drawing their character on the board,
flipchart or mini-whiteboard.
Tip: The key to the success of this activity is to be pedantic when following the students’ instructions! This will encourage students to refine their
instructions.
Challenge students, in their pairs, to design their own ‘wacky monster’ and to write a set of instructions to draw it.
Main Activity
Core: In pairs, using Year 8, Unit 5, Lesson 1, Worksheet 2, the students design and write a set of instructions to draw a ‘wacky monster’.
Extend: Students test their ‘wacky monster’ algorithm on a you or a classmate and refine their instructions based on feedback. They add their revised instructions
to Year 8, Unit 5, Lesson 1, Worksheet 2.
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Plenary
Ask for confident volunteers to test out their instructions on you / rest of the class. As before, be pedantic when following the students’ instructions and ask the
rest of the class to suggest possible improvements. Ask the students: ‘Why is it important to make the instructions clear and precise?’. Explain that a computer
cannot think like us and will follow instructions exactly.
Additional Activity
None.
Digital Resources
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 8, Unit 5: Programming, Lesson 2
Use the ‘turtle’ library in Students should be familiar algorithm, code/coding, PS8.1A Be able to code an algorithm in both a visual and textual
Python to draw regular with algorithms and sequence language
2D polygon shapes programming robots to follow
PD8.1A Understand and use variables and type declarations
a path
PD8.1B Understand and use sequence, selection and iteration
Teaching Summary
In this lesson, students will be using the ‘turtle’ library in Python as a means to gently introduce them to this text-based programming.
Display Year 8, Unit 5, Lesson 2, Worksheet 1 (featuring code samples for 2D shapes) to remind students how they used Scratch in earlier years to draw
shapes. You might want to provide partially completed Scratch code that they can adapt to remind them of techniques from earlier years. This will lead
into using the turtle library in Python (see below).
Load Python and enter the following code to draw a square:
import turtle #Import the turtle library
window = turtle.Screen() #Create a new window
timmy = turtle.Turtle() #Create a new turtle called Timmy
timmy.forward(100)
timmy.right(90)
timmy.forward(100)
timmy.right(90)
timmy.forward(100)
timmy.right(90)
timmy.forward(100)
timmy.right(90)
Explain the simple way in which the code is written and its similarity to the blocks used in Scratch. Students will need to understand and use the following
basic commands:
o forward (move the turtle forward)
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
o backward (move the turtle backwards)
o right (right turn)
o left (left turn)
o penup (pen up)
o pendown (pen down)
o pensize (change the size of the pen)
o pencolor (change the pen colour)
Put the students into pairs and hand out Year 8, Unit 5, Lesson 2, Worksheet 2 . Challenge students to recreate each of the shapes using the turtle library in
Python. (Leave the example displayed on the board / screen to help the students with their code.)
Main Activity
Core: In pairs, students use the software to draw each of the shapes in Year 8, Unit 5, Lesson 2, Worksheet 2.
Support: Place less-confident students into mixed-ability pairs with more confident pupils. Where necessary, supply partial code to be completed – as a
framework/scaffold.
Extend: In pairs, students use the software to attempt to create more complex 2D regular polygon shapes such as triangle, hexagon, octagon or pentagram (five-
pointed star).
Plenary
Ask students to present their solutions to the class and take peer feedback on their solutions. Students should compare and contrast different solutions to the
same problems. Ensure that all students are involved in the discussion. Draw out any misconceptions. Ask: Can anyone think of a way to make this algorithm
more efficient? How could we improve this? What are the limitations of this code?
Additional Activity
None.
Digital Resources
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 8, Unit 5: Programming, Lesson 3
Understand and use Students should have sequence, algorithm, PS8.1A Be able to code an algorithm in both a visual and textual
sequence in an experience of writing algorithms repeat/repetition, loop, language
algorithm counted loop, code
PD8.1A Understand and use variables and type declarations
Understand and use
PD8.1B Understand and use sequence, selection and iteration
iteration (repetition) in
an algorithm
Teaching Summary
Display the terms ‘Repeat’ and ‘Loop’ and ask the students to suggest what each of these words means – draw out answers such as: ‘something that is done
more than once’, ‘something that starts again from the beginning when it has finished’, etc.
Display the two words with their definitions:
o Repeat: An action which is done more than once.
o Loop: A sequence that starts again from the beginning once it finishes.
Introduce the idea of repetition to students by identifying everyday ways in which they will already have encountered it, for example, in dance, repetitive
songs, etc. Encourage students to discuss this with their partner and to Think-Pair-Share some more examples.
Introduce students to counted loops where all repeated actions are indented, for example:
Loop 4 times
Stand
Sit
Ask students to perform the loop as a class.
Put students into pairs and challenge them to create their own counted loop examples which they can act out with their partner.
Main Activity
Core: In pairs, students create their own counted loop examples. They note these down and act them out with their partner.
Support: Support less confident students with the recording of their counted loops.
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Extend: In pairs, early finishers and more confident students can attempt to predict the shapes being drawn by the code in Year 8, Unit 5, Lesson 3, Worksheet 1.
(Answers: A = a square; B = a triangle)
Plenary
Share some of the more complicated counted loop examples with the class, encouraging pairs of students to act them out. Reflect with the students on the key
learning from the lesson.
Display Year 8, Unit 5, Lesson 3, Worksheet 1, which gives an example of a counted loop algorithm using the turtle library in Python. Ask students to discuss with
their partner what will happen if the code is run. (NB: Extend students may already have completed this task, so you could involve them in helping other students
to review and reflect on this activity). Run the code in Python to see if the students were correct in their assumptions and, where necessary, address any
misconceptions.
Additional Activity
None.
Digital Resources
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 8, Unit 5: Programming, Lesson 4
Understand and use Students should understand code, algorithm, repeat/repetition, PS8.1A Be able to code an algorithm in both a visual and textual
sequence in an algorithm the term loop and be able to command, sequence, efficiency, language
identify a loop in Scratch loop, counted loop, RAM,
Understand and use PD8.1A Understand and use variables and type declarations
code subprogram, FOR, WHILE,
iteration in an algorithm
REPEAT PD8.1B Understand and use sequence, selection and iteration
(FOR and WHILE loops)
PD8.4A Be able to locate and fix syntax and logic errors in a
program
Teaching Summary
Context: The term ‘Coding golf’ is derived from the similarity of its scoring system to that of conventional golf, where participants aim to achieve the lowest score
possible. In a game of coding golf, students are given a problem (or working solution) and are challenged to solve it using the fewest lines of code. The idea
behind code golf is to encourage efficient use of code – efficient code is easier to debug, uses less RAM, compiles quicker and uses up less storage space.
[NB: Compiling refers to how long it takes the computer to convert the high-level programming instructions written in Python into low-level binary which the
computer can understand. Hence, the more lines of code, the longer it will take to compile the instructions.]
Display the following example code on the board and ask the students to identify the repeating pattern. (Answer: forward(100) + right(90) are repeated 4 times.)
import turtle
window = turtle.Screen()
timmy = turtle.Turtle()
timmy.forward(100)
timmy.right(90)
timmy.forward(100)
timmy.right(90)
timmy.forward(100)
timmy.right(90)
timmy.forward(100)
timmy.right(90)
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Ask students to suggest ways they could improve the code – draw out answers such as ‘use a loop’, ‘use a counted loop’, ‘use a repeat command’, etc.
Display the optimised solution for the above example:
import turtle
window = turtle.Screen()
timmy = turtle.Turtle()
for loopCounter in range(4):
timmy.forward(100)
timmy.right(90)
Inform students that, in the above example, the code has been made more efficient by using a counted loop. Explain that efficient code uses less RAM,
compiles quicker and uses up less storage space.
Put students into mixed-ability pairs and ask them to copy the optimised example on the board. Instruct students to run the code to see what happens.
Explain to students that they are going to be given a series of challenges which they need to solve using the fewest lines of code possible. Explain to
them that they will be taking part in Coding Golf, and draw the comparison with the scoring system in the conventional game of golf (see above). Tell
students that they can use a combination of features such as loops (FOR, WHILE, REPEAT) or subprograms to achieve their optimised code. However,
readability and usability must not be sacrificed at the expense of code optimisation, therefore white space and comments do not count as lines.
Display the following rules. Explain to students that, in order to make the challenge fair and consistent, they must adhere to these rules:
o Blank lines don't count as lines of code.
o Comments don't count as lines of code. (It is important to encourage students to comment on their code).
o Import turtle, import random etc. do not count as lines of code.
o Everything else counts.
Put the students into pairs and hand out one copy of Year 8, Unit 5, Lesson 4, Worksheet 1 per pair. Explain to the students that their challenge in the
main activity is to write the code to create each shape in the worksheet, using as few lines of code as possible.
Point out to students where the ‘par’ is indicated on the worksheet and explain that they are aiming for this number or below, like in a game of golf.
Before the students begin the activity, hand out a score card (see Year 8, Unit 5, Lesson 4, Worksheet 2) to each pair. Explain to them that they should fill
in this score card as they go along.
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Main Activity
Core: In pairs, students attempt to solve each of the challenges in Year 8, Unit 5, Lesson 4, Worksheet 1. They note down their ‘score’ on each challenge in Year
8, Unit 5, Lesson 4, Worksheet 2.
Support: Students can use Year 8, Unit 5, Lesson 4, Worksheet 3 to help them with the angles for each shape and support them in completing Year 8, Unit 5,
Lesson 4, Worksheet 1. If students are confident to do so, they can note down their ‘score’ on each challenge in Year 8, Unit 5, Lesson 4, Worksheet 2.
Extend: In pairs, students attempt the bonus challenge in Year 8, Unit 5, Lesson 4, Worksheet 4.
Plenary
Ask students to swap places with another pair nearby, and to compare and contrast each other’s solutions to the challenges in Year 8, Unit 5, Lesson 4,
Worksheet 1. Ask them to consider questions such as: Does it solve the problem? How many lines of code have been used? Is any code redundant (does not do
anything useful)? Is one code more efficient than the others? Why? How could you refine your code?
Additional Activity
None.
Digital Resources
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 8, Unit 5: Programming, Lesson 5
Know how to spot and Students will build on their code, computer program, PS8.1A Be able to code an algorithm in both a visual and textual
fix bugs in algorithms knowledge and skills gained in sequence, algorithm, error, language
previous lessons, writing bug, debugging
PD8.1B Understand and use sequence, selection and iteration
programs in Python
Teaching Summary
On a large screen / interactive whiteboard, share Challenge 1 (in Year 8, Unit 5, Lesson 5, Worksheet 1) with students: this offers an example of Python code with
missing or incorrect instructions.
Challenge students, in pairs, to identify the missing code. Set a timer for 2 minutes and ask students for their ideas and feedback. Then, reveal the
solution.
(Missing lines are as follows – Line 10: timmy.forward(100), Line 11: timmy.right(90))
Ask the students what shape they think the code in this challenge will create.
(Answer: a square).
Explain to the students that computer programs often contain several lines of complex code and that, because of this, the programs often contain
mistakes. Tell the students that these mistakes are referred to as ‘bugs’. Explain that an important part of programming is testing your program (also
known as ‘debugging’) to remove all the bugs.
Explain that, in this lesson, students will practise their debugging skills and try to spot the deliberate errors in a selection of code samples.
Put students into pairs and hand out Year 8, Unit 5, Lesson 5, Worksheet 1. This contains a series of code samples for regular 2D polygon shapes with
repeated patterns. Challenge students to predict the shape the code is trying to create and to fix the errors in the code. Point out that an existing
instruction may be incorrect, or an instruction may be missing.
Main Activity
Core: In pairs, students predict the shapes the code samples are trying to create in Year 8, Unit 5, Lesson 5, Worksheet 1 and fix the errors in the code.
Support: Less confident students can use Year 8, Unit 5, Lesson 5, Worksheet 2 to help them predict the shape each code sequence is trying to create.
Extend: When they have finished Year 8, Unit 5, Lesson 5, Worksheet 1, students can create their own 2D shape algorithms containing deliberate errors /
missing code and share them with another student for them to fix.
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Plenary
Ask each pair of students to join together with another pair and compare their answers. Ask students: Is your code the same as the other pair’s? Encourage
students to discuss the reasoning behind their answers. Do they want to adjust or refine any of their code following their discussion with the other pair? Display
the answers to the challenges on the board (Year 8, Unit 5, Lesson 5, Worksheet 3) and go through these with the students. Encourage them to see where they
may have made any mistakes of their own.
Additional Activity
None.
Digital Resources
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 8, Unit 5: Programming, Lesson 6
Understand and use Students will build on their sequence, algorithm, code, PS8.1A Be able to code an algorithm in both a visual and textual
sequence in an algorithm knowledge and experience random, list, response, language
of using Python from question, modify
Understand and use lists in PD8.1A Understand and use variables and type declarations
previous lessons
an algorithm
PD8.1B Understand and use sequence, selection and iteration
PD8.2A Understand and use lists: Items, indices, replacing list
items, slicing; understand and use methods: append, insert, sort;
traversing lists (see iteration)
PD8.3A Understand and use logic operators
PD8.4A Be able to locate and fix syntax and logic errors in a
program
Teaching Summary
Explain to students that a Magic 8-ball is a fortune-telling toy created by Mattel in the 1950s. Inform students that the game works with the player asking the 8-ball
a yes/no style question and the 8-ball replying with an answer such as “Yes”, “No”, “Maybe”, etc. (thereby seemingly being able to predict the future).
In Python, have the following sample running on the board / screen (inform the students that the sample code emulates a simplified version of the classic
magic 8-ball game):
import random
import time
responses = [“yes”,“no”,“maybe”]
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
board / screen:
Positive answers:
● It is certain ● It is decidedly so ● Without a doubt ● Yes definitely ● You may rely on it ● As I see it, yes ● Most likely ● Outlook good ● Yes ● Signs
point to yes
Negative answers:
● Don't count on it ● My reply is no ● My sources say no ● Outlook not so good ● Very doubtful
Neutral answers:
● Reply hazy try again ● Ask again later ● Better not tell you now ● Cannot predict now ● Concentrate and ask again
Tell students that they are going to create their own Magic 8-ball game, using Python.
Put the students into pairs and hand out copies of Year 8, Unit 5, Lesson 6, Worksheet 1. Challenge students to create their own variation of the classic
Magic 8-ball game.
Main Activity
Core: In pairs, students follow the instructions in Year 8, Unit 5, Lesson 6, Worksheet 1 and build their own take on the traditional Magic 8-ball game.
Extend: Students modify their code to use a file rather than a list, with support from Year 8, Unit 5, Lesson 6, Worksheet 2.
Plenary
Direct pairs of students to swap places with another pair in order to try out their Magic 8-ball game. Instruct students to place a comment in the other pair’s code
suggesting at least one improvement. After a few minutes, ask students to return to their seats and to add to their comments: one medal (something they did well)
and one mission (something they could improve upon).
Additional Activity
None.
Digital Resources
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 8, Unit 5: Programming, Lesson 7
Understand and use Students will build on what they sequence, algorithm, PS8.1A Be able to code an algorithm in both a visual and textual
selection in algorithms have learnt in previous lesson. condition, conditional language
They will understand what an switch, action, IF
PD8.1B Understand and use sequence, selection and iteration
algorithm is, and be able to statement, input, output
identify repetition, loops and
patterns in a given algorithm
Teaching Summary
Main Activity
Core: In pairs, students write their own conditional actions where a human input triggers a human output. Students take it in turns to be the human input or output
and act out the program.
In pairs, students write their own conditional switch actions (IF…THEN…ELSE… statements), where a human input starts a human output. For example: IF
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
partner says go THEN stand up ELSE sit down.
Extend: In pairs, students write conditional / conditional switch actions for real-life scenarios. For example:
IF raining, put up umbrella
IF cold, turn up heating ELSE turn heating down
Plenary
Ask pairings to roleplay their algorithms and verbalise their conditional actions using IF … THEN language. Encourage some pairs to share examples from the
extension task.
Encourage discussion by asking questions such as: ‘Which is the condition and which is the action in the example?’ and ‘Is the example a good example of a
conditional action / how could it be improved?’ etc.
Additional Activity
None.
Digital Resources
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 8, Unit 5: Programming, Lesson 8
Understand and use Students will build on their algorithm, sequence, chat PS8.1A Be able to code an algorithm in both a visual and textual
sequence in an algorithm knowledge from the bot, Turing Test, AI language
previous lesson on (artificial intelligence),
Understand and use PD8.1A Understand and use variables and type declarations
selection programmed, instructions,
selection in algorithms
question/response, code, PD8.1B Understand and use sequence, selection and iteration
list, IF statement, ELSE,
PD8.3A Understand and use logic operators
random, function
PD8.4A Be able to locate and fix syntax and logic errors in a program
Teaching Summary
Display the following ‘Thunk’ as the students enter the classroom: ‘Can computers think?’. (A Thunk is a question, with no right or wrong answer, that literally
stops you in your tracks and makes you think. For example, ‘Does a Hard Disk weigh more when it’s full?’ or ‘What colour would a zebra be if it lost all its
stripes?’).
Direct students to the question on the board and allow them to digest and discuss this as they settle.
Read the question aloud and explain that this was a question posed by computer pioneer and artificial intelligence (AI) theorist, Alan Turing. Explain that
Turing proposed that, given time, a computer with sufficient computational power would acquire the abilities to rival human intelligence and that, in order
to test his theory, Turing devised a test.
Tell students that the Turing Test was based on a Victorian parlour game in which a judge (or interrogator) asked a series of questions to a man and a
woman in a separate room. By reading a series of typed answers, the judge must determine which replies were from the man and which were from the
woman.
Explain that Turing adapted the test by replacing the woman with a computer. The aim was to decide whether the answers were from a man or a
computer, thus determining if a computer was able to think for itself.
Ask students: ‘Why is it so hard to make a computer appear as if it is able to think like a human?’ Draw out answers such as: ‘Computers can only follow a
given sequence of instructions’ or ‘Computers can only respond to questions they have been programmed to answer’. Give students prompts where
necessary.
Inform the students that they are going to create a chatting robot (chat bot) that will give the impression it can think like a human.
Introduce the main activity and explain to students that they should work in pairs to follow the step-by-step instructions in Year 8, Unit 5, Lesson 8,
Worksheet 1 to create a chat bot.
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Main Activity
Core: In pairs, students follow the instructions in Year 8, Unit 5, Lesson 8, Worksheet 1 to create a chatting robot (chat bot).
Extend: When students have completed Worksheet 1, provide them with copies of Year 8, Unit 5, Lesson 8, Worksheet 2. Can students add a random pause to
each reply, giving the impression that the computer is thinking? Can they add more possible responses to each of the questions, to make the chat bot appear
more human?
Plenary
Direct pairs of students to swap places with another pair in order to try out their chat bots. Instruct students to place a comment in the other pair’s code suggesting
at least one improvement. For example: add a random pause between each response or create a list of random responses to each question to make it appear as
if the user is talking to a human. After a few minutes, ask students to return to their seats and make any suggested improvements to their own code.
Additional Activity
None.
Digital resources
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 8, Unit 5: Programming, Lesson 9
Understand and use Students will know how to sequence, algorithm, PS8.1A Be able to code an algorithm in both a visual and textual
sequence in an algorithm write simple code. instruction, solution, language
subroutine, subprogram,
Understand and use PD8.1B Understand and use sequence, selection and iteration
function/procedure, code,
subprograms in
program, conditional action PD8.2B Understand and use subprograms
algorithms
Teaching Summary
Prior to the lesson, print and cut out the instructions for making a cup of tea (Year 8, Unit 5, Lesson 9, Worksheet 1).
Challenge pairs of students to put the instructions into the correct order. (The purpose of this challenge is to reinforce their understanding that an
algorithm is simply a sequence of instructions, but to also introduce the idea of subprograms/subroutines.)
Ask students to explain their algorithms. Highlight where there are differences and use these to explain that a problem can have many solutions.
Display the example solution in Year 8, Unit 5, Lesson 9, Worksheet 2, pointing out the conditional actions.
(NB: this is just a possible solution. Don’t worry if students’ solutions do not match this, as the main objective of this task is for students to understand a
sequence of instructions.)
Highlight the instruction ‘Boil the kettle’ and ask students, ‘What is wrong with this instruction?’ Draw out answers such as, ‘What if you didn’t know how to
boil the kettle?’, ‘What if there is no water in the kettle?’, ‘How do you know how much water to put in the kettle’, etc.
Use these answers to identify the need for subprograms / subroutines and explain that some instructions can be broken up further in this way. Explain
that, in a programming context, these subprograms/subroutines are sometimes also referred to as functions or procedures).
Remind the students that, in Lesson 4, they learnt how to make code more efficient by using loops. Explain that program code can be easier to read and
understand when it is broken up into smaller sections. By breaking a program up into these sections (or subprograms), code can be made shorter, simpler and
easier to debug.
Ask students, in their pairs, to write a subprogram / subroutine for boiling the kettle or taking milk out of the fridge. Share some of the students’ examples
with the whole class.
Introduce the main activity – students should work in pairs to write an algorithm for an everyday routine that includes at least one subprogram /
subroutine, for example, making a sandwich or getting ready for school, etc.
Tip: Students can write any algorithm (e.g. making tea, making a pizza, making a jam sandwich, etc.), however, in order to highlight the need for
subprograms / subroutines, it is recommended that students are encouraged to think of more complex daily routines and make their instructions as
detailed as possible. A ‘Getting ready for school’ algorithm, for example, is perfect for demonstrating the need for subprograms as it can be broken up into
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
separate subroutines such as: brushing teeth, taking a shower, making breakfast, etc.
Main Activity
Core: In pairs, students create an algorithm for an everyday routine that includes at least one subprogram / subroutine. Their algorithm should also feature at
least one conditional action (IF…THEN…ELSE statement) that triggers a subprogram. For example, IF requires milk THEN run milk subroutine.
Extend: Challenge students to create a subprogram that passes or returns a variable. For example, add sugar(number of sugars), etc.
Plenary
Select pairs to roleplay their algorithm and ask the class to suggest improvements or ways to refine the algorithm to make it simpler or more efficient. Encourage
reflection with supporting questions such as: ‘Which parts of the algorithm can be improved by using subprograms / subroutines?’, ‘What is the benefit of using
subprograms / subroutines?’ etc.
Additional Activity
None.
Digital Resources
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Year 8, Unit 5: Programming, Lesson 10
Understand and use string Students should have coding, algorithm, string, PS8.1A Be able to code an algorithm in both a visual and textual
manipulation in algorithms experience of manipulating replace, noun, adjective, language
lists from Year 7 user, input, text file
Understand and use lists in PD8.1A Understand and use variables and type declarations
algorithms
PD8.1B Understand and use sequence, selection and iteration
PD8.2A Understand and use lists: Items, indices, replacing list items,
slicing; understand and use methods: append, insert, sort; traversing
lists (see iteration)
PD8.3A Understand and use logic operators
PD8.4A Be able to locate and fix syntax and logic errors in a program
Teaching Summary
Context: Mad Libs is a phrasal template word game where blanks in a phrase are substituted with words suggested by one or more players. The phrase is then
read out aloud with the blanks being replaced with each of the player’s suggestions. In this lesson, the students will create a simple Mad Libs game in Python,
whilst also exploring complex programming concepts such as list manipulation and file handling. To help them with the main challenge, the students will be able to
draw on their experience of using lists in the Magic 8-ball activity (Lesson 6).
Explain to students that today they will be creating a game called Mad Libs in Python. Mad Libs is a word game, usually played at parties, where one
player prompts other players for a list of words to replace blanks in a phrase before reading the phrase out aloud. To demonstrate how the game works,
start today’s lesson with an unplugged version of the game.
Put students into small groups of four or five and hand out a set of five Mad Libs cards to each group (Year 8, Unit 5, Lesson 10, Worksheet 1). Ask each
group to nominate a team captain (this person should hold the challenge cards). Inform the team captains that, for each Mad Libs card (and without
revealing what’s written on the card), they must ask each member of the group to write down a noun. The team captain must then go through each card
and read out the text on the card, each time substituting the blanks with the words suggested by the other team members. Tell students that, as a group,
they must then vote on their favourite answer for each Mad Libs phrase.
Explain to the students that, in this lesson, they will be creating their own version of the Mad Libs word game in Python.
Put students into mixed-ability pairs and hand out Year 8, Unit 5, Lesson 10, Worksheet 2. Challenge students to create their own version of the classic
Mad Libs game in Python.
Main Activity
Core: In pairs, students follow the instructions in Year 8, Unit 5, Lesson 10, Worksheet 2 and create their own version of the Mad Libs game in Python.
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.
Support: Where necessary, support students with identifying suitable nouns and adjectives for their Mad Libs. Instead of asking for a noun or adjective, students
can be more specific in their criteria. For example: object, place, name, animal, etc.
Extend: Challenge students to modify their code so that it displays the randomly chosen Mad Libs first before prompting the user for their response.
Plenary
Direct pairs of students to swap places with another pair in order to try out each other’s Mad Libs game. Instruct students to place a comment in the other pair’s
code suggesting at least one improvement. After a few minutes, ask students to return to their seats and to add to their comments: one medal (something they did
well) and one mission (something they could improve upon).
Finally, ask students to self-evaluate and reflect on the work they have completed through the whole of Unit 5, using Year 8, Unit 5, Lesson 10, Worksheet 3.
Which lesson did they enjoy or feel they were confident/skilful in doing? What one thing would they like to develop more (and why do they need to develop that)?
Students should share their points with a partner, then the class. (You can adapt future teaching based on this feedback.)
Additional Activity
In pairs, students play each other’s Mad Libs games and suggest any improvements / fixes using the comment feature in the code.
Digital resources
© Pearson Education Ltd, 2019. Copying permitted for purchasing institution only. This material is not copyright free.