Cambridge International Catalogue 2024 - Final - Flipbook - Page 36
CAMBRIDGE LOWER SECONDARY COMPUTING
Pages taken from Cambridge Lower
Secondary Computing Student’s Book 8
Interactive 昀氀ashcards
Unit
8.4
Unit 8.4 Testing conditions: Developing games
Testing conditions:
Developing games
SCENARIO
Younger children need to understand the importance
of secure passwords. Your school wishes to promote
online safety and, as a programmer, you have been
asked to create a text adventure game for young
children aged 8–10 years old. The game should
provide the children with some different pathways to
follow as they progress through a story.
The child will play the main character in the game.
They need to find the Chocolate Room in a sweet
shop. They will meet a robot and the sweet-shop
owner on their journey.
When they find and enter the Chocolate Room,
there will be two questions. If the child answers the
questions correctly, they will be given three letters
from a four-letter password. They then have to guess
the password, after being given a clue. If they guess
game.
the password correctly, they open a digital treasure chest and win the
it does, correct errors in
Your challenge is to examine existing program code and find out what
the code and complete the game.
teacher.
your
by
provided
code
sample
different
the
use
You need to
to make sure that it
You will add new code, edit code and test any changes made to the code
works correctly.
Get started!
Have you ever played a game where you had to make choices?
Discuss the following with a partner:
l What sort of decisions did you make in the last game
you played?
l Did you notice that the game progresses differently,
depending on which choices you made?
l Have you every played a game that contained bugs?
Computer programs need to be able to check user choices
and other conditions. They also need to be tested to make
sure that the program runs correctly for everyone.
that run different
In this unit, you will use Python to develop and test computer games
sections of code, depending on the user’s input.
Learning outcomes
In this unit, you will learn to:
statements
l create and follow a flowchart that uses conditional
statements
l develop programs in Python that use conditional
algorithms
l understand how AND, OR and NOT can be used in
NOT
l develop programs in Python that use AND, OR and
types
l develop programs in Python using different data
l develop programs using an iterative process
l develop and apply a test plan
l understand the need for using a range of test data
l test a program using suitable test data.
KEYWORDS
DID YOU KNOW?
This was because
The first adventure games for computers were text adventure games.
A famous example
the computers were not powerful enough to display good graphics.
one of the early
is the game Zork, which you can still play online today. Search for
that time
of
computers
graphics
the
of
quality
the
out
Zork games online to find
could display.
Do you remember?
Before starting this unit, you should be able to:
create an algorithm using flowchart symbols
understand the logic of AND, OR and NOT
understand the difference between integer, real and string
data types
know how to develop programs in Python with inputs
and outputs
use variables in Python
use arithmetic operators in Python
Warm up
did you or your
In pairs, think about your journey to school this morning. What conditions
parents have to check before leaving home? For example:
l Have you brushed your teeth?
l Have you eaten any food?
l Are the doors locked?
l Is your schoolbag packed?
Make a list of all the conditions you can both think of.
conditions depend
Most computer programs also check conditions as they are running. The
in Python, checks
on what the program does. In this unit, you will see how a game, written
important it is to test the
conditions to allow a player to move through it. You will also see how
game, so that it works correctly for every possible choice.
text adventure game:
a game in which
the player types in
commands to control
the main character
program code: the
Python code created
in the IDLE
arithmetic operators:
+, – , *, / and other
symbols that can be
used for arithmetic
Develop
computational
thinking
throughout the
activities.
to debug a program.
5
4
CAMBRIDGE LOWER SECONDARY COMPUTING 7 TEACHER’S GUIDE
8/12/21 2:07 PM
Answers
1 For example:
7.1 Block it out: Moving from blocks to text
Differentiation
Start
Differentiation
Go further
OUTPUT
“Welcome to the
random questions
game.”
Stretch: Some students may be able to add options to their flowchart,
e.g. area of a square,
perimeter of a rectangle, etc. to add further complexity to the flowchart
solution, e.g. an extension
of the flowchart could be as follows:
INPUT
seconds
No
INPUT
hobby
INPUT
name
INPUT
year
INPUT
colour
operation = 5?
star = days +
seconds + year
INPUT
days
Yes
area
area
total = number1 *
number1
No
OUTPUT
“Enter a valid
number”
OUTPUT
“Hello”, name, “it has been nice to
meet you, thank you for telling me
your favourite colour is”, colour,” and
your favourite hobby is”, hobby
OUTPUT
“The area is”
+ area
Stop
Support: Ask these students to focus just on creating the sub-routines
for multiplication and division, e.g.
Start
OUTPUT
“The star number that has been
generated based on your answers
was”, star
multiply
INPUT
number1
number2
operation
total = number1 *
number2
Stop
2 See 7.1.7 ChallengeYourself(Teacher).py for a possible solution.
Expert author
guidance on the
learning models
and approach
to delivering
the curriculum
framework.
operation = 1?
Yes
multiply
OUTPUT
“The numbers
multiplied are”
+ total
Review
l
l
Provide 7.1.7 Worksheet 20. Ask students identify the output based on
the values given using
the flowchart. The flowchart has sub-routines and can be used to check
understanding of
flowcharts with sub-routines.
For answers, refer to 7.1.7 Worksheet 20 Answers.
divide
No
operation = 2?
Yes
divide
total = number1 /
number2
Homework
l
l
Provide 7.1.7 Worksheet 21 electronically, if possible. Students are asked
to create a flowchart for
the scenario given using sub-routines.
See 7.1.7 Worksheet 21 Answers for a solution.
No
OUTPUT
“Enter a valid
number”
OUTPUT
“The numbers
divided are”
+ total
Stop
44
45
34
READY TO ORDER?
hoddereducation ⸀com/cambridge-lowersec-computing
education@hachette ⸀co ⸀uk