International Computing For Lower Secondary Students Book Stage - 8

Download as pdf or txt
Download as pdf or txt
You are on page 1of 201

Margaret Debbadi

Siobhan Matthewson INTERNATIONAL


Series editor:
Peter Marshman
COMPUTING
FOR LOWER SECONDARY

STAGE

8
DIGITAL
COMPUTERINFORMATION
DIGITAL INFORMATION
LITERACY
SCIENCE TECHNOLOGY
LITERACY TECHNOLOGY

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 1 02/05/20 12:35 PM


The Publishers would like to thank the following for permission to ISBN: 9781510481992
reproduce copyright material.
© Margaret Debbadi and Siobhan Matthewson 2020
Photo credits
First published in 2020
p.4 l © antoniodiaz/Shutterstock, rt © nd3000/stock.adobe.com,
rc © Maciek905/stock.adobe.com, rb © Besjunior/stock.adobe.com; This edition published in 2020 by
p. 8 © Aflo/Shutterstock; p. 10 t © Terovesalainen/stock.adobe.com; Hodder Education,
p. 11 © AGPhotography/stock.adobe.com; p. 12 t © Kaspars Grinvalds/ An Hachette UK Company
stock.adobe.com, b © Maksym Yemelyanov/stock.adobe.com; p. 17 Carmelite House
© Stockphoto-graf/stock.adobe.com; p. 45 © Mego-studio/stock. 50 Victoria Embankment
adobe.com; p. 46 © WavebreakMediaMicro/stock.adobe.com; p. 50 © London EC4Y 0DZ
Vermicule design/stock.adobe.com; p. 51 © Ohmega1982/stock.adobe.
com; p. 53 t © Bagotaj/stock.adobe.com, b © Artem/stock.adobe.com; www.hoddereducation.com
p. 57 © Gina Sanders/stock.adobe.com; p. 59 © Beebright/stock.adobe.
Impression number 10 9 8 7 6 5 4 3 2 1
com; p. 61 © Andrea Danti/stock.adobe.com; p. 68 © Gdarts/stock.
adobe.com; p. 89 © Tim/stock.adobe.com; p. 95 © MCStock/stock. Year 2024 2023 2022 2021 2020
adobe.com; p. 126 © Rawpixel.com /stock.adobe.com
All rights reserved. Apart from any use permitted under UK copyright
b = bottom, c = centre, t = top law, no part of this publication may be reproduced or transmitted in any
form or by any means, electronic or mechanical, including photocopying
Every effort has been made to trace all copyright holders, but if any have
and recording, or held within any information storage and retrieval
been inadvertently overlooked, the Publishers will be pleased to make
system, without permission in writing from the publisher or under licence
the necessary arrangements at the first opportunity.
from the Copyright Licensing Agency Limited. Further details of such
Although every effort has been made to ensure that website addresses licences (for reprographic reproduction) may be obtained from the
are correct at time of going to press, Hodder Education cannot be held Copyright Licensing Agency Limited, www.cla.co.uk
responsible for the content of any website mentioned in this book. It is
Cover photo © musicman/Shutterstock.com
sometimes possible to find a relocated web page by typing in the address
of the home page for a website in the URL window of your browser. Illustrations by Aptara, Inc.
Hachette UK’s policy is to use papers that are natural, renewable and Typeset in FS Albert Regular 12/14pt by Aptara, Inc.
recyclable products and made from wood grown in well-managed forests
and other controlled sources. The logging and manufacturing processes Printed in Slovenia
are expected to conform to the environmental regulations of the country A catalogue record for this title is available from the British Library.
of origin.
Orders: please contact Bookpoint Ltd, 130 Park Drive, Milton Park,
Abingdon, Oxon OX14 4SE. Telephone: +44 (0)1235 827827. Fax: +44
(0)1235 400401. Email [email protected] Lines are open
from 9 a.m. to 5 p.m., Monday to Saturday, with a 24-hour message
answering service. You can also order through our website: www.
hoddereducation.com

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 2 29/04/20 8:35 PM


Contents

Introduction 4

8.1 Computer systems: The inside track 8

8.2 Networks and communication: Across the world in an instant 38

8.3 HTML and CSS: Getting your head straight 67

8.4 High level programming language: Expert story telling 95

8.5 Spreadsheet modelling: Model my merch 126

8.6 Relational databases: SegwayThere 158

Glossary 189
Index 195

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 3 27/04/20 6:10 PM


Introduction

About this book


This Student Book will continue to support your progression in computing and in the ongoing
development of the skills needed to progress to specific curriculum areas such as IGCSE Computer
Science and IGCSE ICT. Building on the skills developed in the previous book in this series you will
further develop the technical skills needed to engage effectively in the digital world of today. It
supports the curriculum areas of digital literacy, computer science and information technology:

● Digital literacy focuses on the impact of


digital technology in today’s society. It
promotes understanding of the impact
of the digital world with an emphasis on
maintaining safety and well-being online.
● Computer science is the study of
computational thinking and the creation
of computer programs to solve problems.
It also explores how a computer interprets
and carries out instructions.
● Information technology looks at how to
use computer programs to solve problems.
It takes into consideration both usability
(how well a program works) and accessibility
needs (whether or not everybody is able to
use the program effectively).

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 4 27/04/20 6:10 PM


Introduction

Units
This Student Book has six units:

8.1 Computer systems: The inside track introduces students to the inner workings of
computer systems. It investigates the use of binary number representation and the use
of logic gates for processing and decision making through a scenario around a space
station holiday resort and robotic hosts that support guests during their stay.

8.2 Networks and communication: Across the world in an instant introduces the
concept of networks and methods of electronic communication. The chapter uses the
concept of an e-commerce application to investigate how organisations make effective
use of electronic platforms to support world-wide communication.

8.3 HTML and CSS: Getting your head straight focuses on the development of web
page content using HTML and CSS. In this chapter the focus is on the production of
standardised web page presentations through the use of internal, inline and external CSS.

8.4 High level programming language: Expert story telling provides an introduction
to high level programming through the development of an interactive adventure game
using the programming language Python.

8.5 Spreadsheet modelling: Model my merch further develops skills in the use of
spreadsheet applications. This chapter explores the use of more complex formula
structures to support data analysis, decision making and the use of graphical
presentations. It also investigates how data input can be controlled using validation
methods and cell formatting.

8.6 Relational database: SegwayThere encourages further understanding of the


use of database applications by introducing the concept of relational databases to
effectively store data. It provides a more in-depth look at controlling data input and
ensuring effective management of data output using complex queries and report
structures.

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 5 27/04/20 6:10 PM


Introduction

How to use this book


In each unit you will learn new skills by completing a series of tasks. Each unit starts with some
information followed by a list of the learning objectives that you will cover. These features also
appear in each unit:

Learning Outcomes
KEYWORDS
Important words are
This panel lists the things you will learn about in each unit. emboldened the first
time they appear in a
SCENARIO unit and are defined in
this panel. They also
This panel contains a scenario which puts the tasks into a real-world appear in the glossary.
context.
This panel suggests a
Do you remember? simple task to check
your understanding.
This panel lists the skills you should already be able to do before
starting the unit.
These speech
bubbles provide
Learn hints and tips as you
complete the tasks.
This panel introduces new concepts and skills.

DID YOU KNOW?


Practice
This panel provides an
interesting or important
This panel contains tasks with step-by-step instructions to apply fact about the task or
the new skills and or knowledge from the ‘Learn’ panel. theme.

Computational Thinking

This panel highlights tasks in the unit which involve one of the key areas of computational
thinking:
Pattern recognition: the identification of repeating tasks or features in a larger problem
to help solve more complex problems more easily.
Decomposition: breaking larger problems down into smaller more manageable tasks.
Each smaller task is examined and solved more easily than a larger more complex problem.
Abstraction: ignoring details or elements of a problem which are not needed when trying
to solve a problem.
Algorithmic thinking: providing a series of instructions which include details on how to
solve an identified problem.
Generalisation: the process of creating solutions to new problems using past knowledge
and experience to adapt existing algorithms.
Evaluation: the process of ensuring that an algorithmic solution is an effective and efficient
one – that it is fit for purpose.

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 6 27/04/20 6:10 PM


Introduction

Go further
This panel contains tasks to enhance and develop the skills
previously learnt in the unit.

Challenge yourself
This panel provides challenging tasks with additional instructions
to support new skills.

Final project
This panel contains the final tasks of the unit which encompass
all the skills developed. It can be used to support self/peer
assessment and teacher assessment.

Evaluation
This panel provides guidance on how to evaluate and, if necessary,
test the Final Project.

Student resources are available at www.hoddereducation.com/student-resources

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 7 27/04/20 6:10 PM


Unit Computer systems:
8.1 The inside track
Robots and AI
Robots and artificial intelligence (AI) are used more and more to help
us complete everyday tasks, with future developments now including
studies of how humans interact with machines and how machines can
mimic human behaviour. For example:
Robotics Artificial intelligence

A humanoid robot called Atlas, Voice-activated assistants such as


created by Boston Dynamics, Siri and Alexa use machine learning
combines AI and robotics to tackle and AI to help provide high quality
urban obstacle courses called interactions with human users.
‘parkour’. Atlas the Parkour Robot.
Have a look on the Boston
‘Soft robotics’ is the next Many online shopping applications Dynamics website for
generation of robots; they will be use AI to track users’ internet some great videos.
made of soft materials with a wide searches to target advertising. They
range of motion which can more also make suggestions for purchase KEYWORDS
closely mimic human movement. when the user is next online. robot: a machine
designed to
In this unit you will learn: automatically carry
➜ about the use and impact of robotics and artificial intelligence in the out a pre-programmed
task without human
travel industry intervention
➜ that data is stored and manipulated in binary format inside
computing devices Give an example of
➜ how to use binary representation to store positive numbers what a robot can be
used for.
➜ that alternative representations such as hexadecimal (hex) can be
used to represent data (including colour representations)
artificial intelligence
➜ how to convert numbers from decimal format into binary and (AI): the study
hexadecimal number systems of machines and
application of
➜ how to perform simple additions and multiplications using binary values
algorithms designed
➜ how sound files are stored in computer systems. to carry out tasks in a
way which copies the
SCENARIO way humans think
SpaceVaca is a new travel agent. It specialises in providing trips to binary: a number
system which uses
a holiday resort on a space station. The company wants to offer combinations of two
holiday makers a realisic space adventure where robots are used to digits (0 and 1) to
staff the resort and welcome guests. represent all numbers.
Used to represent data
Your challenge is to research how robots and artificial intelligence in computer systems
(AI) can be used to help humans run the hotel. You will consider hexadecimal (hex): a
the pros and cons of using technology in this way. Once you have number system which
identified potential areas where robots and AI can be used, you will uses a combination
of 16 digits (0–9 and
design a ‘robo-host’ which will be used to perform tasks, such as
A–F) to represent all
welcome new guests to the hotel. numbers

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 8 27/04/20 6:10 PM


Unit 8.1 Computer systems: The inside track

Before you can design the robo-host you will need to consider how
data is stored, manipulated and transferred around a computer system.

Do you remember?
DID YOU KNOW?
Before starting this unit, you should be able to: The word ‘robot’ comes
✔ add two numbers together from a Czech term
‘robota’ which means
✔ multiply two numbers together ‘forced labour’ or
✔ use a spreadsheet to enter basic numbers and formula ‘drudgery’. Robots are
used in, for example:
✔ enter a URL into a web browser to access a specific web • manufacturing (for
page example, when
✔ list a range of input and output devices used with computers building cars)
• space exploration
and other digital devices, for example using keyboards or
(for example, when
microphones or touch screens for input, screens or speakers unmanned robots
for output collect samples from
✔ list a range of sensors used to provide inputs to computers other planets)
• healthcare (for
and other digital devices, for example temperature sensors,
example, to help
humidity sensors, light sensors or motion sensors. conduct surgery
You should also know that: when the doctor
and patient are in
✔ images can be represented in bitmap format different locations)
✔ you can use flowcharts to illustrate the steps involved in
solving a complex problem
✔ data can be input and output using a range of devices
including sensors
✔ sensors and input and output devices can be used to provide
data and receive information from digital devices
✔ spreadsheets can be used to record data and carry out
calculations using formulas.

Robotic holiday

Learn

When we think of robots we may think about how they are used in car assembly plants,
space travel or even medicine. It’s unlikely we would think about using robots and AI in
the travel industry. However, when we combine robotics with AI we can create a machine
that mimics the way humans think and act. A robot can work out solutions to problems
and learn from past experiences as well as carry out the steps to complete a task. For
these reasons, robots are increasingly being used to help travellers in the travel industry.

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 9 27/04/20 6:10 PM


International Computing for Lower Secondary

Hotels and the travel industry also use AI;


sometimes we do not even realise we are
interacting with a machine. Chatbots allow
us to make bookings or ask questions online,
even when hotel or travel agency staff are not
available. Chatbots are now being used by some
health care organisations to ensure patients
have constant access to medical support.
In some countries, robots are used to help
with airport security to detect concealed
weapons. You may have even seen people
walking through airport lounges being
followed by their automated suitcase!
Using technology this way has its pros and
cons. For example:

Pros Cons
● Robots do not get tired, they can work 24 hours a ● High cost of development and maintenance.
day, seven days a week. ● Complex programs needed for their operation.
● Many tasks are completed more quickly by robots. ● Need to be reprogrammed if task changes; cannot
● Tasks are completed to the same standard at all easily handle changes in tasks.
times. ● May be prone to bugs.
● Robots do not need to be paid. ● Security concerns; electronic devices can easily
● Tasks are completed without error. be hacked.
● Robots can work in dangerous environments. ● Staff will need to be retrained.
● Robots can be programmed to interact in many ● Some staff may lose their jobs.
different languages. ● Robots are unable to express emotions and provide
empathy in the same way humans can.

Practice
KEYWORDS
chatbot: a computer
With a partner, discuss the possible ways robotic technology and program designed
AI could be used by SpaceVaca. Think about, and make notes to mimic a human
on, how a robot might be used: conversation
➤ at the point where the customer accesses
You could think Tell your partner about
the SpaceVaca website to make a booking
here about food, an experience you had
➤ when the customer makes their booking drink, payment, using a chatbot.
and pays for their holiday health care.
➤ when the customer arrives at the hotel empathy: the ability to
➤ during the customer’s stay at the hotel understand the feelings
➤ when the customer checks out and leaves the hotel. of another person

Produce a poster advertising SpaceVaca and the robotic and AI


services it provides for its customers. Your poster can be digital
or hard copy. It should include a range of graphics and make
people want to visit the space station for a holiday.

10

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 10 29/04/20 8:39 PM


Unit 8.1 Computer systems: The inside track

Your poster should tell a story to show:


➤ how the customers will use robotic technology and AI for at least three tasks during
their stay or when booking their holiday
➤ how the customer will benefit from using robotic technology and AI for each task
➤ a warning for each task about some possible difficulties or disadvantages of using
robotic technology and AI to complete each task.

Collecting traveller input

Learn
KEYWORDS
digital processing
Digital processing systems such as mobile phones, tablet
system: any system
computers or gaming stations are made up from a combination that processes digital
of electronic hardware devices (such as keyboards, microphones, data (that is, data in
touch screens, sensors) and software which tell the hardware the form of 0s and 1s)
devices how to operate. For the system to be useful to the smart fridge: a fridge
user, there must be a way of providing input (such as voice with internal cameras
and sensors which
input or text input via a keyboard) to the system. This input is
detects what products
then processed using a computer program and the output is are stored inside and
presented to the user. allows users to keep
track of contents;
INPUT PROCESS OUTPUT using internet
Provided by Data is Results of connections they can
the user in the processed using processing are suggest potential
form of data a computer provided for the recipes for users
program user based on the contents
of their fridge
There are many ways users can provide input to and receive
output from digital systems. Some of the most common input and
output devices used with digital devices today are listed below.

Input devices Output devices


● Microphone ● Touch screen for output display
● Touch screen (menu options or ● Speakers for sound output
keyboard entry) ● Printers
● Sensors
● Scanners (image scanners, biometric
scanners)
● Trackpads (to move cursors on screen)

Users can provide instructions to computer systems in a number of


ways.
➤ Users can enter commands from a limited list of instructions
that the system recognises.
• Commands could be selected from a menu using a cursor
and a pointing device such as a mouse (or the user’s finger,
as with the smart fridge example shown here).

11

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 11 27/04/20 6:11 PM


International Computing for Lower Secondary

• Simple instructions from a limited list could be typed into the


device or selected using a keyboard, such as your television
remote control or a touch screen keyboard on a tablet or a
gaming console.
➤ Users can use their own natural language (the language
spoken by humans, using full sentences and phrases without
breaking down instructions into key words or abbreviations)
to enter commands into the computer system.
• Instructions could be spoken into the device using a
microphone; for example, the way we issue instructions to
Siri or Alexa. KEYWORD
• Instructions could be typed into the device using a natural language: the
language spoken by
keyboard using natural language. For example, we can type humans; for example
full sentences into internet search engines to find relevant English, Chinese,
content. Vietnamese, Japanese,
Spanish

Practice

➤ With a partner, discuss the range of ways you can use your
mobile phone. Consider the ways you can provide input and
receive output from your mobile phone.
➤ When you have finished your discussion, your teacher will
give you a copy of a diagram for you to complete to help you
illustrate your findings.
➤ A smart fridge can be used to help with keeping track of food
in the household, ordering shopping, and planning recipes.
Discuss with your partner how AI and robotics could be used in future homes. Design
a robot which can be used in the future to help you complete everyday tasks.
➤ Draw a picture of your robot and write a short description to explain:
o the task it is designed to help you complete
o the input and output devices it will use.

Processing voice input

Learn

Complex programs which use AI are often needed in systems where users can enter
instructions using natural language. For example, when we use voice-activated
instructions with our mobile phones, we tend to speak in full sentences.
But how do these programs work out what the user’s instruction is? Look at the diagram
below; we can see what happens when a user speaks an instruction into a digital device
such as Google Assistant on a mobile phone.

12

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 12 27/04/20 6:11 PM


Unit 8.1 Computer systems: The inside track

Voice input is converted to text


instruction and processed by the computer
system

Computer program carries


Key words are identified from
out instruction identified by
the converted text
key word

Output produced and displayed;


for example on screen or
using a speaker

➤ Instructions are converted to text and the key words identified.


➤ The key words can then be looked up in a list of possible commands.
➤ The instructions relating to those key words are carried out.
➤ Output is produced.

Practice

➤ With a partner, create a table similar to the one shown below. Your table should contain
list of digital devices you use each day. Beside each device, identify possible uses and
then the input and output devices for each use. Decide if you enter commands using
natural language or from a fixed list of commands when completing that task. An
example has been given to help you.
Natural language or
Device Use Input device Output Device Fixed command set
Mobile phone Searching the Touch screen On screen Natural language
internet keyboard display

Game developers are looking at how voice activation can be used to control video games.
Modern remote controls, such as those provided with Apple television, and tools such as
Amazon Alexa, accept voice entry from users. This allows users to carry out many tasks,
such as:
change television channels schedule recordings search for television shows
order goods online search for information book a taxi

➤ Select one of the tasks listed above and recreate the diagram from the previous Learn
panel to include:
o the input instructions a user might use to successfully complete the task
o the key words the computer would use to help it understand the task
o the steps the computer might take to complete the task
o the output the computer would provide to confirm completion of the task.

13

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 13 03/05/20 1:31 PM


International Computing for Lower Secondary

Storing data inside the computer

Learn

Now that we know how instructions can be entered into a computer, let us think about
what it might look like on the inside.
Computers do not recognise and store letters, words or numbers in the same way we
do. Every piece of data stored in a computer is actually stored as a number. Any letters,
symbols, pictures, sounds or videos we store are all converted into numbers. The numbers
used to store all of this data are made up from combinations of 1s and 0s; each 1 or 0 is
known as a binary digit or bit. This is because digital devices are made from millions of tiny
switches called transistors. Each switch can only have one of two values: 1 (ON) or 0 (OFF).
When data is stored inside a computer, the bits used to represent data can be grouped
and processed together in larger units as shown in this diagram. (You might recognise
some of the terms used in the diagram; we use them to help describe how large a file is
and the storage capacity of storage devices.)

Terabyte = 1000 gigabytes

Gigabyte = 1000 megabytes 8 bits grouped together is


called a byte and can be used in
Megabyte = 1000 kilobytes computers to represent a single
character of text on a computer,
Kilobyte = 1000 bytes e.g. the following combinations of
1s and 0s (01000001) is used to
Byte = 8 bits represent the letter ‘A’ on most
computer systems.
Nibble = 4 bits

Bit = 1 or 0 (single binary digit)

KEYWORDS
Practice binary digit: 0 or 1,
the smallest unit of
data represented by a
With a partner create a rhyme or poem which can be used to computer
help you remember the terms associated with units of storage bit: short for binary digit
from the diagram shown above. transistor: a tiny switch
that can be activated
Illustrate your poem with graphics to give an example of each
by electrical signals. If
unit of storage; for example, a bit is 1 or 0 so you could show the transistor is ON it
those numbers or an image of a transistor (or switch) used to represents 1, when it is
represent 1 or 0. Or you could use an image of an external hard OFF it represents 0
drive storage device to represent 1 TB (terabyte) of storage byte: a group of 8 bits,
capacity. often used to represent
a single character in a
computer

14

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 14 02/05/20 12:43 PM


Unit 8.1 Computer systems: The inside track

Using binary to store text

Learn

If our digital devices are storing all of our data as 1s and 0s, then how do we use binary to
represent the letters and characters which make up the words and phrases we enter into
the computer?
The set of characters that can be represented on any device is known as its character
set. The character set is made up from all of the letters, numbers, punctuation symbols
and special characters represented on a device. Each character will be represented by a
distinct set of 1s and 0s.
Most devices use a common code so that the characters can easily be transferred from one
computer to another. One of the most commonly used codes is the American Standard Code
for Information Interchange (ASCII) (this can be pronounced as ‘as-kee’).
Remember
ASCII is a 7 bit code used to represent all of the keys on a standard
there are 8 bits
keyboard. The table below shows some of these 7 bit codes. However, as in a byte.
computers normally store information in 8 bits, an extra bit is added to the
beginning of the ASCII code to make it up to 8 bits. Each byte contains a
unique combination of 0s and 1s to represent each character on a standard keyboard.
ASCII ASCII ASCII ASCII
character Binary character Binary character Binary character Binary
Space 0100000 8 0111000 P 1010000 h 1101000
! 0100001 9 0111001 Q 1010001 i 1101001
“ 0100010 : 0111010 R 1010010 j 1101010
# 0100011 ; 0111011 S 1010011 k 1101011
$ 0100100 < 0111100 T 1010100 l 1101100
% 0100101 = 0111101 U 1010101 m 1101101

When a key is pressed on a keyboard the ASCII code for that character is generated
using a group of eight electrical pulses. For example pressing R on a keyboard causes 8
transistor switches to be on or off in a particular pattern shown in the diagram.

Pressing ‘R’ on a keyboard will generate the 8-bit ASCII code 01010010 (remember the
eighth bit is just an extra 0 at the start) which can be processed by the computer.

0 1 0 1 0 0 1 0

Further examples: ‘H’ = 0100 1000 and ‘i’ = 0110 1001, so the word ‘Hi’ would be
represented as the following pattern of 1s and 0s 0100 1000 0110 1001.

15

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 15 03/05/20 1:31 PM


International Computing for Lower Secondary

Practice KEYWORDS
character set: The set
of characters that can
Search the internet for a list of ASCII codes used to represent be represented on any
the letters A-Z and a-z. Show how the following words would be device
represented in ASCII. special characters:
symbols and other
➤ school characters (aside
➤ computer from standard
letters, numbers and
punctuation symbols)
which can be created
Pattern recognition using a standard
keyboard, such as #, ~, %
Examine the list of ASCII codes found during the previous American Standard
practice task. What patterns do you notice with the characters? Code for Information
Interchange (ASCII):
Discuss these with a friend.
a standard code used
to represent text on
computers and other
Abstraction electronic devices

The combinations of binary values listed below all represent


phrases or questions that some guests have said to the robo-
host. Using the ASCII code charts you have found on the Remember that the table
internet, translate these binary values into English for the shows the 7 bit codes but the
manager of the space station. values shown here are the 8
bit versions, with an extra bit
✪ 0100 0100 0110 0101 0110 1100 0110 1100 0110 1111
at the beginning!
✪ 0101 0111 0110 1000 0110 0001 0111 0100 0111 0100 0110
1001 0110 1101 0110 0101 0110 1001 0111 0011 0110 1001 0111 0100
0011 1111

Decomposition

A guest has just asked the robo-host the following two


questions.
✪ Can I check in now?
✪ What is my room number?
Use your ASCII code table to create the binary code the
robo-host would use to represent these questions.
Think about
Use the process of decomposition to break down this how long it took you to
problem. translate these messages.
Your computer is carrying out
✪ You may wish to look at one character at a time.
billions of these conversions
✪ Does the same character appear twice? How can per second!
you speed up the process of translating the words?
If you have time, send some messages to your friend
using the ASCII code.

16

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 16 27/04/20 6:11 PM


Unit 8.1 Computer systems: The inside track

Using binary to store numbers


Learn

When we enter numbers into a digital device


we may need to perform calculations using
those values. For example, using a spreadsheet
application to add two numbers together.
When numerical values are used for calculations
computers cannot use the ASCII code to carry out
these calculations. Instead the numbers are stored
in binary number format. The binary number system The prefix ‘bi’ means two. Just like a bicycle
got its name because it uses two symbols, ‘1’ and ‘0’. is called a bi-cycle because it has two
wheels.
Decimal number system
Before we think about how binary numbers are represented let us revise the decimal
number system. The decimal number system is the formal name for the numbers that we
use every day.
Every number we want to represent in the decimal number system is made up from the
ten digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. When you were younger you used units, 10s, 100s,
1000s, and so on, to help you understand the value of numbers greater than 9. For
example, when we refer to the number 2409, what we actually mean is:

Thousands Hundreds Tens Units


1000 100 10 1
2 4 0 9
= 2 × 1000 = 4 × 100 = 0 × 10 =9×1
2000 + 400 + 0 + 9
Each column
Each column can only contain one
heading is worked out by of the digits 0-9. But
multiplying the previous heading depending in which column
by 10. So, if we added another that digit is placed, it could
column to the table, its heading mean, for example, 9, 90, 900,
would be Ten thousands 9000 and so on.
(1000 × 10 = 10 000). This is known as
place value.

So, the number 2409 is actually calculated as 2000 + 400 + 0 + 9.


Decimal is also known as base 10 due to the fact that it contains 10 distinct digits (0–9).

KEYWORDS
binary number format: numbers represented using 1s and 0s
decimal number system: number system using the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
place value: the numerical value a digit has as a result of its position in a
number; for example, the number 24 actually represents (2 × 10) + (4 × 1)
base 10: another term for decimal as it is based on 10 digits

17

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 17 27/04/20 6:12 PM


International Computing for Lower Secondary

Practice

Rewrite the following numbers using the ➤ Nine thousand


table layout from the previous page to ➤ Nine hundred and nine
show how the place values of a digit can ➤ Seven thousand nine hundred and nine
alter its overall value in a number. Your ➤ Seventy four
teacher will provide you with a copy of
these tables in the document Place Value
Revision Exercise.docx.

Binary number system


When working
Learn with more than one number
system it is a good idea to use a
subscript to distinguish one from the
We have seen that binary has only two digits 0 and 1. For this other. For example, if this number were
reason, the place value column headings in binary increase in written with a subscript 10 (1001011010)
multiples of 2 and each column can only contain 0 or 1. the number would be ten million,
So, for example, here is a binary number: 100101102. The ten thousand, one hundred
subscript lets us know the number is a binary number. Here and ten.
is what this actually means:
Each column heading value is worked out by multiplying the previous heading by 2
     64 × 2   32 × 2 16 × 2 8×2 4 × 2    2 × 2   1×2

128 64 32 16 8 4 2 1
1 0 0 1 0 1 1 0
= 128 × 1 = 64 × 0 = 32 × 1 = 16 × 1 =8×0 =4×0 =2×0 =1×0
128 0 0 16 0 4 2 0
 
the digit or bit to the left hand side of the number is the digit or bit to the right hand side of the number is
known as the Most Significant Bit (MSB) as it has the known as the Least Significant Bit (LSB) as it has the
largest place value. smallest place value.

So, the number 100101102 represents 128 + 0 + 0 + 16 + 0 + 4 + 2 + 0


which is 15010. We use a subscript 10 to let us know that this is a decimal value.
Now that we understand how the place values work, we can easily convert any binary
number into decimal. Binary is often referred to as base 2 (think about decimal being
known as base 10 to help you understand why this might be the case).
Here are two more examples:
Example 1: 101100002
128 64 32 16 8 4 2 1
1 0 1 1 0 0 0 0
= 128 × 1 = 64 × 0 = 32 × 1 = 16 × 1 =8×0 =4×0 =2×0 =1×0
128 0 32 16 0 0 0 0
So, 101100002 = 128 + 32 + 16 = 17610

18

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 18 27/04/20 6:12 PM


Unit 8.1 Computer systems: The inside track

Example 2: 000011112

128 64 32 16 8 4 2 1
0 0 0 0 1 1 1 1
= 128 × 0 = 64 × 0 = 32 × 0 = 16 × 0 =8×1 =4×1 =2×1 =1×1
0 0 0 0 8 4 2 1

So, 000011112 = 8 + 4 + 2 + 1 = 1510


When binary
We still use 1 byte (or 8 bits) to represent 1510 in binary even numbers are being stored
though we do not really need the first four bits of this in memory, each bit is
byte (which are set to zero). This is because computers represented by a transistor
normally store data in fixed length groups of 8 bits. In which can either be OFF or ON
the past, computers could only process 8 bits at a time. to represent
0 or 1.
So, even though we only need 4 bits to store the number 15
we always represent binary numbers using all 8 bits, including all
of the zeroes.
When we think about how the number 15 is stored in computer memory we could also
think of it as being stored using transistors as:

OFF OFF OFF OFF ON ON ON ON

Practice KEYWORDS
Most Significant Bit
Use the tables below to show how the following binary numbers (MSB): the digit to the
would be represented in decimal format. left hand side of the
number; the bit with
(a) 128 64 32 16 8 4 2 1 the largest place value
1 0 0 1 1 1 0 0 Least Significant Bit
(LSB): the digit to the
128 64 32 16 8 4 2 1 right hand side of the
(b) number; the bit with
0 1 1 0 0 1 1 0 the smallest place
value
128 64 32 16 8 4 2 1
(c) fixed length: having
0 0 0 1 1 1 1 0 a set number of bits
to represent a value;
128 64 32 16 8 4 2 1 for example, numbers
(d) in binary are normally
1 0 0 1 0 1 1 0
shown using 8 bits

128 64 32 16 8 4 2 1
(e)
1 1 1 1 1 1 1 0

19

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 19 27/04/20 6:12 PM


International Computing for Lower Secondary

Algorithms and decomposition

✪ The hotel manager cannot understand how decimal numbers can be stored in computer
memory as 0s and 1s and asks you to explain this process.
o Open a blank spreadsheet file and save it as Binary Conversion.
o Set up a spreadsheet similar to the one show below.

Binary Digits: Each cell in this row contains one bit. The 8 bits together can represent
a binary number which is stored in computer memory.

ON/OFF: This row shows the ON/OFF pattern for each transistor used to store the
binary digit shown in the row above.

Processing: This row calculates the decimal value of each bit entered in row 2 by
multiplying the bit stored by its place value in the number.

Decimal Value: Calculates the number stored by adding together place values
multiplied by either 1 or 0 depending on the bit stored in each memory location.

o In cell I:4, enter a formula that will correctly convert the binary
digit entered in cell I:2 into its decimal equivalent. All formulas should
o Replicate this formula across the row, from cell I:4 to B:4, to start with =
calculate the decimal values for all bits in the binary number
entered. The formula in cell I:4
should perform the
following calculation
cell I:2 * cell I:1

To do this add
o Add a formula to cell B:6 which will calculate the decimal value being
all of the values in cells
stored.
B:4 to I:4. You could use
the spreadsheet function
SUM here.

20

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 20 27/04/20 6:12 PM


Unit 8.1 Computer systems: The inside track

o Enter a set of 8 binary digits into the spreadsheet to test it works correctly; for
example, we know that 00001111 should generate the decimal value 15.

✪ We can use the ON/OFF row in the spreadsheet to see how this binary number would be
stored by a computer using 8 transistors. Each transistor can be switched ON or OFF.
o Enter the following formula into cell B:3:

Test the value


of B:2 to see if
the value is 0.

If the value in B:2 is 0, the transistor should be switched OFF to


represent 0.

If the value in B:2 is not 0, the transistor should be switched


ON to represent 1.

o Replicate this formula across the spreadsheet from cell B:3 to I:3 to work out if each
of the other ‘transistors’ would be ON of OFF.
o Test your spreadsheet using the binary code for 27 (00011011).
o Entering 00011011 should produce the following results.

✪ Ask a friend to test your spreadsheet with binary number representations they have calculated
themselves. Ask them to complete this table to show the output from your spreadsheet.
Your teacher will provide you with a copy of a table to complete, with these headings:

Binary number entered ON/OFF transistor pattern Decimal value generated

21

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 21 27/04/20 6:12 PM


International Computing for Lower Secondary

Decimal to binary
Learn

Humans arriving at the space station hotel will need to be able to communicate with
the robo-host. We know the robo-host only understands binary. Any numbers input
into the robo-host must be converted from decimal into binary.
The easiest way to convert a number from decimal format into binary is by using the
‘divide by 2’ method.
We have already shown how the number 17610 would look in binary format. Let us look at
how the ‘divide’ by 2 method does this conversion.
➤ Divide the original decimal number by 2 and
176 ÷ 2 = 88 remainder 0
write down the remainder. (The remainder will
88 ÷ 2 = 44 remainder 0
always be either 0 or 1.)
44 ÷ 2 = 22 remainder 0
➤ Divide the result by 2 and record the
22 ÷ 2 = 11 remainder 0 remainder.
11 ÷ 2 = 5 remainder 1 ➤ Repeat the first two steps until the result of
5÷2 = 2 remainder 1 the division by 2 is 0.
2÷2 = 1 remainder 0 ➤ Write out the binary result from left to right
1÷2 = 0 remainder 1 starting with the last remainder produced:
10110000
For example, a guest will think of their room number as being the decimal number 176
but the robo-host will store this in binary format as 101100002.

Algorithmic thinking and abstraction

A guest arriving at the space


station hotel must provide START Result of
division = 0?
the robo-host with their room
number so their bags can be Divide
number by 2
taken to their room. Multiply each
remainder value by its place
Using the flowchart on the value heading in
right, your task is to design an the byte

algorithm which can be used Write out binary


place headings
to convert decimal numbers 128, 64, 32, 16, 8, 4, 2, 1
provided by guests into binary
format so the robo-host can N Write out remainder
values from left to right,
understand them. Flowchart starting with last
statements have been provided Y remainder
but three are unnecessary. Add the results
Use the process of abstraction of each multiplication

to remove the unnecessary Record result


steps and then complete STOP
and remainder
the algorithm by placing the
remaining steps in the correct
position in the flowchart.

22

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 22 02/05/20 12:48 PM


Unit 8.1 Computer systems: The inside track

Practice
Look carefully at
the subscript value before
The robo-host has provided the hotel manager with some
carrying out your conversions, not
information about hotel guests but it has output some of all values are in binary format.
the information in binary format. Use your spreadsheet/algorithm
Help the hotel manager by converting binary numbers from the previous practice
below so they contain the correct decimal value. task to help you
with this.

SP CE HOTELS

• There are 000101112 guests booked into the restaurant tonight.

• To date, there are 101101002 bookings for next year.

• There have been 0011011110 queries about bookings for next year.

• There are 110011002 staff working in the space hotel today.

Use your
spreadsheet/algorithm
The robo-host needs to record details of how many guests are from the previous
staying on each floor on the space station. A staff member practice task to help
entered the following digital values using a touch screen. you with this.
Convert the highlighted decimal values into 8 bit binary values
for the robo-host. Show your working out:

SP CE HOTELS

Floor 1 Floor 2
32 guests 127 guests

Floor 3 Floor 4

54 guests 76 guests

23

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 23 02/05/20 12:49 PM


International Computing for Lower Secondary

Binary calculations
Learn

The robo-host will be used to complete a range of tasks for guests and staff during their
stay at the space station hotel. For example, it could help the manager work out how
many guests are staying in the hotel at any one time, or it could calculate a total bill for
guests at the end of their stay.
It is quite easy to add binary numbers together – the hardest calculation you have to do is 1 + 1.
We all know that 1 + 1 = 2. But how do we represent 2 in binary?
Remember, the number 2 is written in binary as 102.
128 64 32 16 8 4 2 1
Remember that binary
0 0 0 0 0 0 1 0
only uses two digits 0 and 1
= 128 × 0 = 64 × 0 = 32 × 0 = 16 × 0 =8×0 =4×0 =2×1 =1×0 so the biggest number we could
0 0 0 0 0 0 2 0 ever produce by adding two
digits together is 210 or,
This is what we are doing when we add binary values: in binary, 102.
Stage 1 Stage 2 We then add
Binary place values 2 1 2 1 the carry to any other
values in the column. In
0 1 0 1
this case there are none, so
Adding + 0(1) 1 + 0(1) 1 we write down 1 under the
1 + 1 gives us an 0 1 0 next place value
answer of 0 and we heading.
carry the 1 across to
the next column.

In binary addition, when adding two numbers, you come across the following possible
outcomes:
➤ 0+0=0
➤ 1+0=1
➤ 1 + 1 = 0 carry 1 (which is 2 in decimal or 10 in binary)
➤ If the carry value is added to a column that is already adding 1 + 1 then you get:
1 + 1 + 1 = 1 carry 1 (which is 3 in decimal or 11 in binary)
Now look at some more complicated binary additions:
Example 1: 0102 + 0112
Binary 4 2 1 Decimal calculation
place values
0 1 0 2 Remember: 1 0 12 = 510

+ 0(1) 1 1 + 3
1 0 1 5 4+0+1

Just like adding in decimal, we start on the right hand side and continue adding and carrying until all columns
are complete.

24

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 24 29/04/20 8:42 PM


Unit 8.1 Computer systems: The inside track

Example 2: 0112 + 0112

Binary place values 4 2 1 Decimal calculation


0 1 1 3
Remember: 1 1 02 = 610
+ 0(1) 1(1) 1 + 3
1 1 0 6
4+2+0
Look at the second column in this calculation. With the carry, we are now adding 3 binary
digits and the answer is 1 + 1 + 1 = 112 (3). So, we write down 1 and carry 1 to the next column.

Practice

Complete the following 8-bit binary additions to test your knowledge of this content.
Part 1
Calculate the results of these 8-bit binary additions and convert each answer into
decimal.
0 1 0 0 0 1 0 1
(a)
+ 0 0 0 0 1 0 1 0

0 0 1 0 0 1 1 0
(b)
+ 1 0 0 1 0 0 1 0

0 0 0 1 1 0 1 1
(c)
+ 1 1 0 0 0 1 1 0

Part 2
Show how the following calculations could be carried out in binary format:
(a) 12 + 2
Calculate the binary for 12 using the method shown in the Learn box on page 22.
Calculate the binary for 2.
Add the two binary values together.
128 64 32 16 8 4 2 1
Binary for 12
Binary for 2
Result

25

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 25 29/04/20 8:44 PM


International Computing for Lower Secondary

(b) 32 + 10
Calculate the binary for 32.
Calculate the binary for 10.
Add the two binary values together.
128 64 32 16 8 4 2 1
Binary for 32
Binary for 10
Result

Hexadecimal number system


Learn
Hex Decimal Binary Hex Decimal Binary
When programming the robo-host it
0 0 0000 8 8 1000
can be difficult to write out lines of
1 1 0001 9 9 1001
binary code as all of the 1s and 0s can
be confusing. Some computer 2 2 0101 A 10 1010
programmers often use a more 3 3 0011 B 11 1011
human-friendly method of re-writing 4 4 0100 C 12 1100
binary values. One of these methods is 5 5 0101 D 13 1101
the hexadecimal (hex) number system.
6 6 0110 E 14 1110
The hexadecimal number system 7 7 0111 F 15 1111
(also known as base 16) uses the
characters 0–9 and A–F; that’s 16 characters in total.
The table shows how the hexadecimal characters correspond to the decimal and binary values.
A 4 bit number is called a nibble. The largest 4 bit number is 11112 or 1510. This means one
hex character can represent a nibble.
A byte has 8 bits. We can split each byte into two nibbles and represent A nibble is
each one using a hexadecimal character. This allows us to represent a four bits – half
byte with 2 hexadecimal characters. a byte.

For example, the number 21510 can be represented as 110101112 in binary.


Write 21510 as an 8 bit binary value. 1101 0111
Split the byte into two nibbles …
… and treat each nibble as a separate number. 1101 0111
Show the decimal value for each nibble. 13 7 01112 is 710 in
Show the hexadecimal value for each nibble. D 7 decimal; 710 is 716
in hexadecimal

11012 is 1310 in
decimal; 1310 is D16
in hexadecimal

26

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 26 29/04/20 8:46 PM


Unit 8.1 Computer systems: The inside track

So, 11010111 can be re-written in hex as D716.


To prove this is correct, let us take D7 16
Take the hex values. D 7
Use the place
values method
Calculate the decimal value for each. 13 7 shown on page
Convert the decimal into binary nibbles. 1101 0111 21 to convert
Bring the two nibbles together to form 1 byte. from binary to
1101 0111 decimal.

110101112 = 21510 which was our original number.

Practice KEYWORDS
base 16: another
Using the processes outlined in the previous section, carry out name for hexadecimal
the following decimal to hex and hex to decimal conversions. because it is based on
16 characters
(a) Convert the number 12910 into hexadecimal. nibble: a 4 bit number
Write 12910 as an 8 bit binary value.
Split the byte into two nibbles …
… and treat each nibble as a separate number.
Show the decimal value for each nibble.
Show the hexadecimal value for each nibble.

(b) Convert the number 17010 into hexadecimal.

Write 17010 as an 8 bit binary value.


Split the byte into two nibbles …
… and treat each nibble as a separate number.
Show the decimal value for each nibble.
Show the hexadecimal value for each nibble.

(c) Convert the number B316 to decimal.

Take the hex values. B 3

Calculate the decimal value for each.


Convert the decimal into binary nibbles.
Bring the two nibbles together to form 1 byte.

2 = 10

27

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 27 29/04/20 8:47 PM


International Computing for Lower Secondary

(d) Convert the number AD16 to decimal.


Take the hex values. A D

Calculate the decimal value for each.


Convert the decimal into binary nibbles.
Bring the two nibbles together to form 1 byte.

2 = 10

Other uses for hexadecimal


Learn

In computing systems, the hexadecimal number system has


proven very useful. One of the most well-known uses for
hexadecimal is for specifying colours on web pages in HTML.
All colours on a website are combinations of shades of red, green
and blue, or RGB. Red, green and blue can each have 256 different
levels of intensity, which are indicated by numbers between
0–25510. In binary these numbers range from 00000000–11111111. In
hex however these numbers range from 00–FF.
Web browsers specify colours using the format #RRGGBB (Reds,
Greens and Blues) where the # is used to show the number is in
hex. Using this system two hex digits are used for each colour: so
#FF0000 uses all Red with no Green or Blue. Think how
In binary this would be: long it would take
to edit colours on a web
R R G G B B page if you had to enter
F F 0 0 0 0 the binary code for each
colour, and how easy
1111 1111 0000 0000 0000 0000 it would be to make a
mistake.
As one number the hex value #FF0000 is
1111111100000000000000002 .
Instead of having to type in long binary numbers when changing There are
the colour of text on a web page, a programmer can write the 256 red × 256
short hexadecimal code. These six digit hexadecimal numbers green × 256
can represent 16 777 21610 different colours. blue = 16 777 216
total colours.

28

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 28 29/04/20 8:49 PM


Unit 8.1 Computer systems: The inside track

Some examples are shown below.

Maroon Red Orange Yellow Olive


#800000 #FF0000 #FFA500 #FFFF00 #808000

Purple Fuchsia White Lime Green


#800080 #FF00FF #FFFFFF #00FF00 #008000

Navy Blue Aqua Teal


#000080 #0000FF #00FFFF #008080

Black Silver Grey


#000000 #C0C0C0 #808080

Practice

Convert the following binary number representations into their


colour names by splitting each number into nibbles and working
out the hex vale for each nibble.
➤ 1111111100000000111111112
➤ 1000000010000000100000002
➤ 1111111111111111111111112

Decomposition and pattern recognition


The manager of the space station would like you to design an icon which can be
displayed on a touch screen display on the robo-host.
Customers will press the icon to complete standard tasks such as:
✪ Check-in
✪ Request room service
✪ Book a table in the restaurant
✪ Book a shuttle taxi home
The icon will be made up from a bitmap image. The pixels in the image will be coloured
using a 4-bit binary code. Each of the 4 bits displayed can also be represented in their
hexadecimal equivalent.
Before designing your icon you will need to complete a colour mapping grid. This grid includes
the hex values 0–F and the decimal equivalent of each hex value. You must assign a colour to
each hex value and then calculate the binary equivalent for each hex character. You can assign
any colour you wish to each hex value but you will need to assign 16 colours in total.
You should then complete the icon design using the binary code for each pixel colour.

29

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 29 02/05/20 12:49 PM


International Computing for Lower Secondary

✪ Open the file BinaryDesigns provided by your teacher. It contains an electronic copy of a
grid with a key for you to complete.
o Use the key to devise your own colour chart to assign a colour to the hex characters shown.
o On the grid, design your own icon for the task you have selected but enter the
codes for your selected colour using the appropriate 4-bit binary combination
instead of the hex code. For example:
On my colour key, I am using F 16 to represent the colour RED.
Hex Decimal Binary Colour
F 15 1111 RED
My icon has a 10 pixel red line across the top. Therefore, I have shown the code for
RED in binary in each of the pixels in the top line:

1111 1111 1111 1111 1111 1111 1111 1111 1111 1111

o Give your completed key and grid to a partner and ask them to colour it in for you.
o Discuss with a partner which method (binary or hex) is better for colour encoding
and why?

Decomposition

You will need to use the process of decomposition to help you


solve this problem and break down this challenge into these
stages:
✪ Assign a colour name to each hexadecimal value in the grid.
✪ Calculate the binary representation for each hexadecimal value in
the grid (and, therefore, each colour).
✪ Design your icon using any of these colours.
✪ Find the colour that you wish to use for a pixel.
✪ Find the hex equivalent for the colour.
✪ Convert the hex into binary.
✪ Record the binary value in the correct pixel location on the grid.

30

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 30 27/04/20 6:12 PM


Unit 8.1 Computer systems: The inside track

What about the sound?


Learn
KEYWORDS
analogue: a
Today, most digital devices accept input from users, via continually varying
microphones, in the form of spoken words. They can also provide signal, for example a
speech output to the user via speakers. The robo-host uses voice sound signal
recognition to identify guests when taking orders or giving them analogue to digital
access to their rooms. When a sound is produced, it creates what converter (ADC): used
we call an analogue sound wave such as the one shown below. to convert analogue
signals, such as the
human voice, to digital
signals
sample rate: the
number of sound
samples taken each
Computers do not store data in analogue format so the sound second
must be converted into digital format which can be stored as hertz: a unit of
bits. Converting analogue signals into digital is carried out by a measurement which
tells us how many
device called an analogue to digital convertor (ADC). sound samples were
ADCs take samples of the sound wave at fixed intervals in time. The taken in a single
number of samples taken each second is called the sample rate. second
The sample rate is measured in ‘number of times per second’ which
is known as hertz (Hz). So, for example, if the sample rate was 1 Hz
this would mean that only one sample was taken per second.
The diagram below shows an analogue sound wave which has
been sampled 20 times in one second.

Sample 2 Sample 3

111
110 Analog input
Binary values

101 Digital output


100 Sample 20
011
010
001 20 samples have
000 been taken in one
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 second here, so the
Time sample rate is 20 Hz.

Sample 1

Each sample has been represented using three binary digits as


shown using the values on the y-axis of the graph shown above. For
example:
Sample 1 = 100
Sample 2 = 101
Sample 3 = 110
… and so on, up until

31

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 31 02/05/20 12:51 PM


International Computing for Lower Secondary

Sample 20 = 011
In this example we are using 3 bits to store each sound sample. The
number of bits used to store each sound sample is called the bit depth. KEYWORD
bit depth: the number
The more samples taken and the more bits used to record each of bits used to store a
sound sample, the better the quality of the digital sound file. single sound sample

Practice

The robo-host needs to ensure that guests’ sound samples are not confused. A decision
needs to be made regarding how many bits should be used for each sound sample. Your
teacher will give you a worksheet to allow you to complete this task.
Complete the sampling of the sound wave shown below. The sample 10 samples
rate is 10 Hz. per second.

11

10
Binary values

01

00
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time

This sample is recorded using only two bits (a bit depth of 2). How accurate is the sound sample?
Now try sampling the same sound wave using 4 bits (1 nibble).
1111
1110
1101
1010
1001
Binary values

1000
0111
0110
0101
0100
0011
0010
0001
0000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time

How does this 4-bit sample compare with the previous 2-bit sample? What happens to
the quality of the samples taken? Discuss what you notice with your partner.
Which bit depth would you recommend and why?

32

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 32 02/05/20 12:52 PM


Unit 8.1 Computer systems: The inside track

Go further
We saw earlier how the robo-host may need to perform complex calculations where the
result being calculated needs more than one bit to represent it; for example, 1 + 1 = 2 (which
is 102 in binary).
To recap, add the following 8 bit binary numbers:
(18 + 2)
000 1 00 1 0
+ 000000 1 0
(20 + 4)
000 1 01 00
+ 000001 00
What happens when we try to add larger numbers? For example, a customer’s We are
bill for room service might include $193 for food and $93 for soft drinks. able to use 8 bits
How would the robo-host do the calculation 193 + 93? to represent the
answer produced
Binary place values 126 64 32 16 8 4 2 1 Decimal calculation from these
1 1 0   0 0 0 0 1 193 calculations.
+ (1) 0(1) 1 0 1 1 1 0(1) 1 + (1) 9 3
(1) 1 1 0 1 1 1 1 0 286

Something called overflow now occurs, This is
because the result needs more than 8 bits if it is KEYWORD
to be stored correctly.
overflow: when
the number being
The largest 8 bit binary number is 111111112. In decimal this is represented is too
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 25510. large for the number
However when we add together the decimal numbers 193 + 93, of bits available
the result is 28610. We cannot represent this as an 8 bit number
as it is too large and so the result of our binary addition is incorrect. This is
Use the
known as an overflow error. layout shown
As we have seen, computers store data in groups of 8 bits. The additional above to help
1 needed at the beginning when we add the final carry is a ninth bit which you add the 8 bit binary
would need to be stored in another 8 bit memory space rather than in the numbers provided
original 8 bits used to store the two numbers being added. in the scenarios
below.
The robo-host is expected to perform calculations and output results for
staff when they are producing bills for customers. Help the robo-host create bills for the
following customers by adding up their bills using a pen and paper. Circle any overflow
produced from the calculations.
◆ Mr Y has booked two rooms for his family who are staying for one night. The first room
is charged at 001100112 and the second smaller room is charged at 001100012.
o What is the total cost of his stay? Show your answer in binary and decimal.
◆ Family A have a bill for 10110112 from the restaurant and 111000102 for their two night
stay at the space station.
o What would their total bill be? Show your answer in binary and decimal.

33

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 33 02/05/20 12:25 PM


International Computing for Lower Secondary

Challenge Yourself
Arithmetic shifts KEYWORD
arithmetic shift: a
Earlier, we looked at how we can add binary numbers together to process of shifting
help us determine, for example, a customer’s total bill for staying binary digits left or
at the space station: right to help perform
complex calculations
Family A have a bill for $113 per night for a two night stay in
the space station, plus a $91 stay for the restaurant.

To work out the total bill the robo-host would have to multiply the
cost of 1 night by 2 to work out the cost of the hotel room first.
How would the robo-host work this out?
Think first about how we multiply numbers in our decimal number
system. When we multiply by 10 in the decimal system we simply
See page 18
shift all of the numbers to the left and add a 0 as the least
to revise Least
significant bit.
Significant Bits .
This is called carrying out an arithmetic shift.
Multiplying by 10
2 0
× 1 0
shift ‘20’ one place left → 2 0 0 ← add 0 into blank position

Arithmetic shifts in binary operate in exactly the same way.


The difference is that in binary, shifting one place to the left
multiplies by 2, since binary uses two digits instead of ten.
So, if we want to multiply a binary number by 2 we simply shift
the binary digits 1 place to the left and then fill the missing space
on the right hand side with 0
For example, to multiply the binary number 1012 by 210:
Fill blank
128 64 32 16 8 4 2 1 under least
0 0 0 0 0 1 0 1 significant bit
with 0.
Now shift 1012 (highlighted in yellow) one place to the left and
add a zero in the right hand column:

128 64 32 16 8 4 2 1
Shift left by 1 0 0 0 0 1 0 1 0
Shift left by one
The original number was 000001012, which is 510 in decimal. place the bit under the
heading for 2
The new number is 000010102 which is 1010 in decimal. So, we have (this has the same effect
multiplied the original number by two: 510 × 210 = 1010. as multiplying by 2).

34

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 34 29/04/20 8:51 PM


Unit 8.1 Computer systems: The inside track

➤ Use this process of binary shifts and additions to carry out the
following calculations in binary:
o 610 × 210 You will have to
o 1210 × 210 calculate the binary for
o 910 × 210 each of the values in the
calculation first. Convert 11310
Now use what you have learned to into binary first of all
calculate the total bill for Family A. and then use an arithmetic
shift to calculate the cost of
Family A have a bill for $113 per night for a two night stay in the two nights. Add the results
Space Hotel plus a $91 stay for the restaurant. of the binary
shift to the binary
Show your answer in decimal format. value for 91.

Final project
Part 1: Introducing the robo-host
Now that you understand how the robo-host will collect and process data from the space
station customers, you can design the robo-host. Your first task is to consider what input
and output devices the robo-host will need to allow it to interact with customers.
➤ Copy and complete the table below to show the input devices and the output
devices that your robo-host will require and state what each will be used for.

List of input devices List of output devices

➤ Draw a picture of your robo-host. You should label all of the input and output devices
it will use. Include also a description of how your robo-host will move around the
space station.
➤ With a friend, discuss how the introduction of the robo-host might:
● impact on jobs in the space station hotel
● positively and negatively affect the experiences of guests at the hotel.
➤ Copy and complete the following table to summarise your discussion.

Impact on jobs

Impact on guests
Positive impact Negative impact

35

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 35 27/04/20 6:12 PM


International Computing for Lower Secondary

Part 2: Abstraction and pattern recognition


When each guest arrives at the space station, they must record their voice pattern with
the robo-host. The voice pattern is used to allow them to give instructions to the
robo-host.
➤ Help the robo-host select the correct digital sound
sample for guest X.

Analogue sound pattern recorded for guest X


111
110
Binary values

101
100
011
Which digital
010
sound sample most
001
closely represents
the original sound
000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 pattern recorded
Time
for guest X?

Sound sample 1 Sound sample 2


111 111
110 110
Binary values
Binary values

101 101
100 100
011 011
010 010
001 001
000 000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time Time

Sound sample 3 Sound sample 4


111 111
110 110
Binary values

Binary values

101 101
100 100
011 011
010 010
001 001
000 000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time Time

36

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 36 02/05/20 12:53 PM


Unit 8.1 Computer systems: The inside track

Part 3: Decomposition and abstraction


Mr T has been staying at the space station hotel for three nights.
The tariff is: Use what
you have already
Accommodation $50 per night × 3 = $150 learned about binary
Food total: $98.00 shifts and addition to
help you with this task.
➤ Help the robo-host calculate his bill. You should do all
calculations in binary and show your answer in binary. Show your
working out as you go along.
➤ Show your answer in hexadecimal format.

Evaluation

➤ Examine your designs for your robo-host and ensure you


have included:
o input devices
o output devices
o information on how the robo-host can move around the
hotel.
➤ Ask a partner for their thoughts on your robo-host design
(Part 1). Based on the feedback what changes would you
make to your design?
➤ Discuss your findings on the impact of the robo-host on
jobs and guests with a partner with another table. Expand
your table to include any new ideas you have learned from
your discussion.
➤ Check your calculations with a friend to ensure you have
produced the correct total for Mr T’s stay at the space
station. If your answers are different work through the
calculations together and highlight any mistakes you made,
making corrections if necessary.

37

481992_U1_Int_Com_Low_Sec_SB_001-037.indd 37 27/04/20 6:12 PM


Networks and communication:
Unit
8.2 Across the world in an instant

e-communications: across the world in an instant KEYWORDS


Businesses use many forms of digital communication to create an online emoji: a graphic
which is a visual
business community. representation of an
emotion
In this unit you will learn about:
➜ how businesses use emails, emojis and messaging applications
Draw three emojis.
➜ VoIP and video conferencing
➜ using social media to help businesses
➜ digital communication systems: LANs and WANs Voice over Internet
Protocol (VoIP): using
➜ using web browsers to view material online the internet to make
➜ using technology safely telephone calls
➜ threats to cyber security.
video conferencing:
using the internet
to transmit pictures
SCENARIO and sound between
computers
You are the new e-communication manager for an online retailer
social media:
called e-Shop. e-Shop is working to increase the number of customers websites that allow
it has across the world. It is making use of social media, email and users to create and
video conferencing. In the recent past, e-Shop has decided to look at share content or to
participate in social
social influencers to improve sales. You have been asked to assess the networking
many methods e-Shop plans to use to communicate with its world-
wide customer base and between its many offices and staff. Your
task is to build up a portfolio of information to: Which social media do
you use most often?
• help staff understand what methods of communication they
should use and when
• make sure staff understand the technology that allows them to local area network
(LAN): a network
communicate online spread over a small
• make staff aware of the risks associated with online communication geographic area like a
• help staff to communicate respectfully and responsibly online. building

What is the name of


Do you remember? the LAN used at your
school or home?
Before starting this unit you should be able to carry out the
following:
wide area network
✔ Use the internet to research. (WAN): a network
✔ Use a word processor to create a report. spread over a large
geographic area such
✔ Use email software to send, receive and forward emails.
as a country
web browser:
software which allows
KEYWORD Name one the user to view web
cyber security: the different ways in which we protect networks, type of cyber pages on the world
programs and data from attack and unauthorised access security. wide web

38

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 38 27/04/20 6:13 PM


Unit 8.2 Networks and communication: Across the world in an instant

Emails, emojis and messaging applications

Learn

Email or electronic mail allows users to send messages from a computer across the
internet at any time. Emails can be read at any time by the recipient. To use email, users
must have all of the technology required to connect to the internet.
Email is one of the most important communication tools that e-Shop uses. Every staff
member has their own email address made up of a user identifier followed by the @
symbol and the domain name, eshop.com.
An example of an email address at the shop is:
[email protected]
In this example, Jolong is the user identifier, and eshop.com is the domain name.
Staff use email to contact customers, suppliers, each other, and other businesses. Staff
receive about 100 emails every day and they must manage the communication.
Staff use email to create and reply to messages. In addition, there are other features
which are useful to the team at e-Shop.

Feature Description
Forward This feature is useful if a staff member receives an email which is really for someone else;
they can forward the email to the correct person.
Distribution List Staff at e-Shop regularly have to send emails to certain groups of people. For example,
as communications manager you will have to send emails to the managing directors.
Instead of sending individual emails you can set up a distribution list and add all of
the relevant people to the list. Then you only need to type the email once and add the
distribution list in the To… section of the email.
Attachment e-Shop staff have to send documents such as bills or receipts to customers. The
attachment feature allows staff to add these documents to an email.
Read Receipt If an important email is being sent, e-Shop staff must make sure that the recipient has
read the email. When this is the case, the staff member will select an option which will
request a read receipt. When the recipient opens the email, they will be asked to allow a
read receipt to be sent.
Delayed delivery Staff can prepare emails in advance and schedule when the email should be sent. This
is useful if the email is to be sent at a particular date or time, for example at night. The
email can be prepared during the day and will automatically be sent at the correct time
at night.

KEYWORDS
user identifier: the part of the email address which uniquely identifies the user
domain name: the address of the server which holds the email

39

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 39 27/04/20 6:13 PM


International Computing for Lower Secondary

Here is a typical email window showing some of the features mentioned.

Voting options
This is the email sent to all of the employees of e-Shop by the Secretary of the
Entertainment Committee. He wants them to vote for a location for the annual company
dinner. The voting option is being used.

You can
The sender of the see that the
email enters the ‘Use Voting
email addresses Buttons’ is
of the recipient(s) checked.
here.

The sender
The secretary
enters the email
has requested to
address of
delay the delivery
people receiving
of the email,
a carbon copy
using the ‘Delay
(Cc) of the email
Delivery’ option.
for information
purpose only.
The secretary has asked for
The sender enters the email a read receipt and, therefore,
address of people receiving the ‘Request a Read Receipt’
a blind carbon copy (Bcc) of box is checked.
the email. These recipients
will not see any of the other
recipients’ email addresses.

40

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 40 27/04/20 6:13 PM


Unit 8.2 Networks and communication: Across the world in an instant

In Microsoft Outlook, when


clicking ‘Use Voting Buttons’
the Properties dialog box
opens.
You can see that the options
‘Sandy Beach, Forest Green
Park, Dining Room at e-Shop’
are entered in the ‘Use voting
buttons’ box.
As the secretary has asked for
a read receipt, when the email
is opened, staff will be asked
for a read receipt.
When you send an email
you do not have to send it
immediately. You can delay
sending it. The secretary wants
the email to be sent at 17:00 so that
employees do not discuss it during the
working day. So, the ‘Do not deliver
before’ box has been ticked and a date
and time have been entered.
On receiving this email, staff will be able
to vote using a ‘Vote’ button. The Vote
button will show the options and the
staff member can make their choice.
When they make a selection a message
box confirming their selection is shown.
The secretary will also receive a read
receipt.
Afterwards, the secretary can track
responses using the tracking button. Votes are
automatically counted.

41

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 41 27/04/20 6:14 PM


International Computing for Lower Secondary

Decomposition and algorithmic thinking

Complete the steps required to create an email to your friends inviting them to your
birthday party. In the email you should ask them to vote for one of three places for the
party. (Select your favourite three places.)
✪ Open email software
✪ Create a new email
✪ Add recipient addresses to the ‘To …’ line
✪ …………………….
Using an email tool of your choice, try out the steps above.
Review the steps and add the missing steps (or delete any unnecessary steps).
Make sure the steps are in the correct order.

Practice

Using an email application of your choice, complete the following tasks.


➤ Research how you create a distribution list in your email application. Then create a
distribution list of three of your friends and draft an email which will inform them of
the launch of a new product at e-Shop. The email should invite them to the launch
which is going to be held at a top hotel. Guests should dress for dinner and a celebrity
will attend. (You can select the hotel and the celebrity to include in your email.) Send
the email to your three friends via the distribution list.
➤ As editor of your school’s online magazine, you must email all of the team members
about the front page story for this month’s magazine. The suggested themes are:
o successful sporting pupils: an article about the three top athletes in the school.
o musician of the year: an article about the best musician in the school.
o artists’ corner: an article about the new Art Club which has started in the school.
Using an email tool of your choice, create an email about the story and send it to the
members of the team.
o Choose three of your friends as team members and set up a distribution list.
o Ensure you add information to the ‘Subject’ line which will tell the team what the
email is about.
o Use voting buttons so that the team members can vote for one of the three
suggested themes.
o Request a read receipt.
o You must carbon copy your class teacher into all emails about the magazine.
o You must blind carbon copy the web designer into the email because you cannot
share the email addresses of pupils or teachers with other people.

42

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 42 27/04/20 6:14 PM


Unit 8.2 Networks and communication: Across the world in an instant

Learn

Subject line
The subject line tells the recipient what the email is about. It is important to think about
the subject line as you compose an email. People do not want to read a lengthy subject
line and most email providers do not show the full subject line. It is important to keep it
short to ensure that people want to open your email.

Watch your tone


The tone or mood of the email is important. You need to make sure that the correct
message gets across to the recipient. Common mistakes include people writing an email
in a hurry. The email can sound too abrupt. Remember you do not have gestures or your
voice to support your message in an email.
Compare the following pairs of statements – in each case, both say the same thing but
use different tones.

Please send me your monthly report immediately. ✘ Please send me your monthly report immediately – we’ve
got a new boss and he has asked us to produce our papers
on time this month! ✓
You promised to send me the final payment yesterday I need to sign-off the final payment. Can you please
and you still haven’t sent it. ✘ send it now. ✓

Always think carefully about the wording of an email. Read it aloud or print it and read it
to ensure the tone is correct.

Know your audience


Emails should be audience-centered. That is, you should take time and think about
the people for whom you are writing the email. The target audience should direct the
content of the email. You need to think about the age, location and gender of the target
audience. This is very important for e-Shop as they use email for marketing. They need to
send relevant emails to people.

Email pros and cons

Advantages of using email Disadvantages of using email


● Emails can be sent anytime. The recipient does not ● Technology – the sender and recipient must have
have to wait to receive them. Emails are stored in the access to the internet.
inbox for reading at any time. ● It is easy to insert a wrong address into the ‘To…’
● Emails are delivered instantly to any location in the world box. A confidential email could be sent to the wrong
and to any number of people using distribution lists. person.
● They are inexpensive and in most cases free. ● Spam – unwanted emails selling or advertising prod-
● Filtering of email can be carried out protecting users ucts can be sent. This is like electronic junk mail.
from junk mail and phishing emails. ● Users are not notified of new emails unless they are
● The sender can attach any type of file to the email. logged on to the email system.
Sound, graphics and text files can be easily distributed.

DID YOU KNOW?


There are more than 3.2 billion email accounts in
existence. That’s nearly half the population of Earth.

43

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 43 27/04/20 6:14 PM


International Computing for Lower Secondary

Practice

➤ As e-communications manager, you have received the following two emails from
trainees. With a partner, review the emails with regard to tone and state which is most
likely to be effective and why.

Email from Trainee 1 Email from Trainee 2


hey, Hi Miss Zheng ,
i need help with my I am in your trainee class on Wednesdays, and I have a question about the
training manual, can training manual that we have to create for next Tuesday. I’m not sure that I
i come by your office understand what is meant by the following sentence in the question:
tomorrow “Comment on how e-Shop use online communication to provide
thx excellent help to customers.”
I am not sure what would count as “excellent” help.
Can I call to your office tomorrow at 2:00 pm to discuss my question?
Please let me know if that suits your schedule. If not, I could also call on
Thursday after 3:00.
Thank you,
Anna Lau

➤ Here are two versions of an email from a supervisor, Jan More, to a group of her
staff at e-Shop. With a partner review the emails. Which version do you think is most
effective and why?

Version 1 of Jan More’s Email Version 2 of Jan More’s Email


Subject: this evening Subject: materials for Friday Project Meeting
As you know, this evening we’ll be meeting Hi, everyone—
to talk about the progress of each of our For tomorrow’s 6 p.m. project meeting in the
current projects. Coffee and biscuits will be lecture room, please bring 10 copies of the
provided. Please arrive on time and bring the following materials:
documents you have been working on this
Your project calendar
week—bring a copy for everyone. Some of
these material might include your calendars, A one-page report describing your progress so
reports, and any important emails you have far
sent. Also, I wanted to remind you that your A list of goals for the next month
building access requests are due on Friday; Copies of any progress report messages you
please send these to Ms Gray at reception or have sent to clients this past month
if she is not there when you call please email
See you tomorrow—
them to her.
Jan

➤ You should discuss the subject line, tone and how appropriate the text of the email is
for the intended audience.
➤ Jan has asked to borrow your office for a team meeting. The last time she borrowed it
she left the office in quite a mess. Write an email to Jan explaining that she can borrow
the office but that she must ensure that she leaves it in a tidy state at the end.
➤ You have received a customer complaint about a product sold by e-Shop. The
customer found the product to be broken on receipt. Write an email apologising to the
customer and suggesting a way in which you will compensate them.

44

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 44 27/04/20 6:14 PM


Unit 8.2 Networks and communication: Across the world in an instant

Learn

Interactive messaging systems


e-Shop also makes use of interactive
messaging on its website. The company
uses a chat facility to help customers make
selections and complete the ordering
process. It provides quick, immediate
and relevant help using a text window.
Customers type their questions and a
member of staff at the other end is there
to help. Live chat provides a different
experience to email. There are no large
sections of text and the answers are
specific to the question.
e-Shop uses a messaging app called ChatNow to send notifications to customers. This is
cost effective and allows e-Shop to send interactive messages such as videos, products
or reviews from customers.
ChatNow can be used to communicate with friends and family. You can do this by setting
up a group of people who have joined the app. Text and voice messages can be sent
easily to everybody in the group. Users can send stickers, videos or photographs and
all members of the group can see them instantly. It is also possible to send any of these
items to other users who are not in the group. ChatNow allows you to communicate and
respond very quickly with your friends and family.

Pros and cons of messaging apps

Advantages of using messaging apps Disadvantages of using messaging apps


● It is fast as communication is immediate and ● Users have to be registered on the app to receive informa-
mobile phones are used by everybody. tion and they must provide personal details .
● Simple to use even for beginner users. Very ● Users need to remember to keep their profile private so that
little knowledge or experience is required. only people that they know can contact them.
● More people read messages with notifications ● Staff could use the application to talk to friends during work.
than will read email. ● Staff need to be trained in the use of ChatNow, and e-Shop
● Multimedia messages containing video, needs to make sure that it protects any details held about
sound, animation and text can be sent. customers.

Using Emoji
Emoji is a tool to exhibit nonverbal communication. An
emoji is a visual representation of an emotion. Emoji are
commonly used in informal communications between
friends. However, they can be included in more formal
email communications to soften the tone. Emoji are useful
for overcoming language barriers and expressing emotions.
However, they should be used with care in business emails.
e-Shop uses emoji in the interactive chat on the website and on the messaging app, but
the company has asked staff not to use them in business emails.

45

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 45 27/04/20 6:14 PM


International Computing for Lower Secondary

Practice
KEYWORDS
multimedia: a mixture
Recently, e-Shop has launched a new product aimed at 18–30 of sound, video,
year old customers. There is a recommendation that the product animation and text
should be launched using ChatNow. Prepare a report, using a nonverbal
word processor or presentation tool such as Microsoft PowerPoint, communication:
to present the arguments for and against using ChatNow. Your communication made
without speaking such
report should refer to:
as gestures
➤ the target audience
➤ multimedia Name one example
➤ speed of communication. of nonverbal
communication.

Video conferencing and VoIP

Learn

Video conferencing (VC)


e-Shop has a number of offices
across the world. Every month
the senior managers from
these offices ‘meet’ using
video conferencing.
Video conferencing uses the
internet to transmit pictures
and sound between computers.
Video conferencing can be done using a mobile personal device
like a tablet or phone or on a desktop computer using a webcam,
speakers and a microphone.
Mobile phone technology with software such as Skype and
Facetime has made video conferencing accessible to anyone
with a smartphone. e-Shop carries out interviews for new staff KEYWORDS
using this technology.
high bandwidth:
Video conferencing can also be carried out using purpose-built bandwidth refers to
video conferencing systems. e-Shop has a video conferencing suite the amount of data
filled with equipment which helps reduce costs for the company. that can be transferred
on a communications
Using video conferencing means that people based in different line in a given time
locations can ‘meet’ without travelling. This means that face to telecommunications
face meetings can be held with individuals from different places link: using technology
all over the world. The company saves money on travel and the like fibre optic cables,
computers are linked
workers can meet without the inconvenience of travelling. to the internet; the
e-Shop is also concerned about the pollution aspect of travel and link is the channel that
so it wants to reduce its carbon footprint. The managing director allows communication
between computers
sees video conferencing as one way to do this.
and the internet

46

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 46 27/04/20 6:14 PM


Unit 8.2 Networks and communication: Across the world in an instant

Transmitting pictures and sound together requires a high


bandwidth telecommunications link such as a fibre optic. Low Think of bandwidth as a
bandwidth means that the images and sounds will not arrive together corridor in your school.
and the overall quality of the video will be poor. The wider the corridor
(bandwidth), the more pupils
Different types of connections provide different bandwidths. For (data) can pass through
example, a fibre optic connection can carry up to 10 gigabits per without stopping.
second.

Pattern recognition

One gigabit is equal to 1 000 000 000 bits. One character can be sent using
8 bits. How many characters could be contained in one gigabit?

Video conferencing requires the following equipment.


➤ A video camera or webcam to transmit pictures.
➤ Microphone and sound system to transmit and receive sound.
➤ A screen to view other participants.
➤ A high bandwidth telecommunications line.
➤ Video conferencing software.

Advantages of video conferencing Disadvantages of video conferencing


● Allows collaboration with team members across the world. ● High cost for initial setup.
● Allows collaboration with people from other companies. ● Specialist training may be required
● Visual and audio contact means that meetings are more like normal to make use of a purpose-built VC
face-to-face meetings. system.
● Full multimedia presentations can be shared during meetings (for example, ● Network performance may be poor
someone can share their computer screen containing a presentation). when VC is in operation.
● Meetings can be set up on-demand by connecting up to the videolink. ● A high bandwidth is required to
● No travel costs for the company. ensure good performance.
● No travel time for the employees.

Voice over Internet Protocol (VoIP)


VoIP enables you to use the internet to make telephone calls. A major advantage of this
type of phone call is that charges are not incurred for individual calls.
All sales staff at e-Shop have company smartphones. The company has instructed
them to use VoIP when calling clients. VoIP calls can be made on a wide range of
devices, including a tablet, mobile phone and laptop. The device must be connected to
the internet.
Using VoIP you can call anyone, anywhere on any type of telephone or network.
The call will sound the same as an ordinary telephone call. If you call someone on another
VoIP device the call quality is much better than an ordinary call because voice signals are
being transmitted digitally.

47

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 47 27/04/20 6:14 PM


International Computing for Lower Secondary

When a person is speaking into a microphone the sound that their voice makes is converted
to electrical currents that are in analogue format. A computer can only accept data that is
in digital format therefore the electrical signal must be converted. An analogue to digital
converter (ADC) is used to do this. The ADC is normally a sound card inside the computer.
The ADC converts the electrical signals from the microphone into digital data that the
computer can understand. For more information on how an ADC works see section 8.1.
Analogue electrical Digital data is in
data sent to computer binary format,
such as11010010

Analogue sound signals ADC converts analogue Digital data received


converted by microphone data to digital data which the by the computer
into analogue electrical signals. computer can understand.
The sound card is the ADC.

KEYWORDS
microphone: an input device used to enter sound into a computer
sound card: a hardware device inside a computer which can convert analogue
sound signals to digital data

Practice

➤ As e-communications manager you have been asked to create a guidance document


for staff about VoIP and video conferencing. Open the document called VCVOIP.docx,
provided by your teacher, and complete the document using the information you have
about VC and VoIP technologies.
➤ e-Shop wants to replace their current VC suite with a new HD VC system. Using the
internet, research the new HD technology and provide a one page report which shows:
o current prices for HD VC equipment
o the features of HD VC equipment
o the system that you would recommend for the company
o a photograph of your recommended system.

Keeping it all social KEYWORDS


ranking: the position in
Learn which the company’s
website sits when an
Social media plays an important role in e-Shop’s marketing internet search is done.
The higher the ranking
strategy. The company uses Facebook, Twitter, Instagram and
the more popular the
many of its employees are members of LinkedIn. website is
e-Shop has added a link back to the website and is hoping to
achieve increased sales and increased traffic to the website. In Choose a topic and
turn, if the number of customers visiting the website increases Google it. Which site
they should see an improved ranking on search engines. is ranked number 1?

48

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 48 03/05/20 1:33 PM


Unit 8.2 Networks and communication: Across the world in an instant

KEYWORDS
Multimedia and two-way conversation is possible within social
social influencers:
media, leading to greater customer engagement.
individuals who make
This, in turn, will bring an opportunity to conduct market research use of social media
about the customers and help improve products and services. and whose opinions
and actions can
Social media helps e-Shop to reach a larger number of influence other users
customers world-wide. This has led to greater access to of social media
international markets and improved networking opportunities
with customers and other businesses. e-Shop wants to take Name a social
advantage of this and is thinking about using social influencers influencer that you
to help market their products. follow.

Successful social influencers spend a lot of time building trust


with their followers. Followers become loyal and they believe digital footprint: the
in the person they are following. As a result they trust their digital data held about
recommendations and are likely to purchase the products they a person as a result of
their online activity
recommend.
big data: the large
Businesses collect data about our online activities as we move volume of data
through social media applications. This data helps them to create that is created by
digital devices and
a profile on our online or browsing habits. We create a digital
websites every day;
footprint. it is analysed using
The data generated by all the users of a social network is vast computer programs
volume: the amount of
and is described as big data. The 3Vs (volume, variety and
data generated
velocity) are three defining properties of big data: variety: the number of
➤ volume refers to the amount of data different types of data
generated
➤ variety refers to the number of types of data
velocity: the speed of
➤ velocity refers to the speed of data processing. data processing

Practice
As e-communications manager you have decided to use social influencers to improve
e-Shop’s marketing. These people are usually well known on social media and will help
the company promote some of its products to particular groups of people. Many of the
staff do not understand what you mean by ‘social influencer’. So you have decided to find
two examples of these people and present their stories to the staff.
➤ Using the internet, research and identify two young social influencers who are helping
businesses to market their products. You should identify the companies they work
with and how they have helped the company. Prepare a poster about the two young
influencers which you can display in the marketing department. The poster should
explain their role in marketing e-Shop’s products.
➤ Produce a questionnaire for adults to complete to collect information on the ways
they make use of each of the social media applications (at home and at work, for their
social and working lives).
➤ Social media has impacted most businesses. They use it to advertise their products
and build customer loyalty.

49

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 49 27/04/20 6:14 PM


International Computing for Lower Secondary

Companies also use it to organise contests and give away prizes. Use the internet to
research and find two companies who target young people in this way.
➤ Use your research findings to complete the document socialmedia.docx, provided by
your teacher.
➤ Technology has changed the way in which we live and work. Digital media, such as
photographs and videos, can be sent around the world in seconds and can be easily
INFOGRAPHIC
copied for free. Research each of the following music recording devices. Then create
a timeline, showing how the recording of music has evolved. Include: 4-Track (Stereo-
Pak), 8 Track, MP3, Blu-ray disc, Compact cassette, Compact disc, and DVD.
➤ Here is an example of a timeline template. You would need to replace the text and
dates with your own.

TITLE LINE 02 TITLE LINE 04 TITLE LINE 06


2017 2019 2021
Lorem ipsum dolor sit amet enim. Lorem ipsum dolor sit amet enim. Lorem ipsum dolor sit amet enim.
Etiam ullamcorper. Suspendisse a Etiam ullamcorper. Suspendisse a Etiam ullamcorper. Suspendisse a
pellentesque dui, non felis. pellentesque dui, non felis. pellentesque dui, non felis.
Maecenas malesuada elit lectus Maecenas malesuada elit lectus Maecenas malesuada elit lectus
felis, malesuada ultricies. felis, malesuada ultricies. felis, malesuada ultricies.

TITLE LINE 01 TITLE LINE 03 TITLE LINE 05

Lorem ipsum dolor sit amet enim. Lorem ipsum dolor sit amet enim. Lorem ipsum dolor sit amet enim.
Etiam ullamcorper. Suspendisse a Etiam ullamcorper. Suspendisse a Etiam ullamcorper. Suspendisse a
pellentesque dui, non felis.
Maecenas malesuada elit lectus 2018 pellentesque dui, non felis.
Maecenas malesuada elit lectus 2020 pellentesque dui, non felis.
Maecenas malesuada elit lectus 2022
felis, malesuada ultricies. felis, malesuada ultricies. felis, malesuada ultricies.

➤ You could use a graphics package, such as Adobe Photoshop, or a word processor to
create your timeline. Your timeline should include a picture of each device, the year in
which it was created and a description of how it works. Identify clearly the different
digital music formats.
➤ Discuss with a friend whether, due to social media, the musician’s work is better
protected now or in the past.
➤ Using social media generates big data. Data, such as a person’s location, age and
gender, can be collected when they use social media.
o Suggest two other pieces of data that might be collected.
o How could the company use these data items to help sell its products?

How does it all happen?


Learn
Staff within an organisation need to know how to use the
technology safely and how to protect the data on the networks
from cyber attack.
Networks: LANs and WANs
Networks are collections of computers and other hardware
connected together. Organisations use networks to share
information and resources. Networks are supported by a variety
of hardware and software without which they could not function.

50

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 50 27/04/20 6:14 PM


Unit 8.2 Networks and communication: Across the world in an instant

e-Shop’s communication is supported by different types of DID YOU KNOW?


networks. A network is made up of a number of computers linked The internet allows
communication
together using wireless or wired connections. Computers which
between any device on
are linked together like this are able to share devices like printers any continent regardless
and scanners. They can also communicate with each other. of oceans or mountains.
This is possible because
the data can travel
over long distances
using fibre optic cables
underground and under
the ocean. Cables have
been laid as deep as
8000 metres under the
ocean. These cables
are coated in layers of
metal tubing, plastic,
rubber and other
substances to protect
them.

KEYWORDS
There are different types of networks. Some are made up standalone computers:
of just a few computers linked together. Others have many computers which are
computers linked together in one building or school. These not connected to a
are called local area networks (LANs) because they are linked network
peripherals: hardware
together on a single site or small geographic area.
connected to a
Data is transmitted from one computer to another along the network such as
network cables or wireless connections. printers and scanners.

e-Shop uses computers connected to a LAN rather than


Which peripherals do
standalone computers. It is more convenient for the company to you use at home?
organise its computers like this because:
➤ expensive peripherals (such as printers) can be shared file server: the main
between computers; for example, one printer or scanner can computer on the
be used by several computers on the network network; it is more
powerful than all of the
➤ software is stored on the file server and this is shared other computers with
by all the computers on the network; the file server is the a large amount of RAM
most powerful computer on the network – it is used to and hard disk space
communicate with and manage all of the other computers
➤ a network allows users to communicate with each other via A wired
email or video conferencing connection uses a physical
➤ users can share files and work on joint projects using link, like copper cables or
shared resources and folders on the network; these files fibre optic cables, to connect
and folders are stored on the file server computers. A wireless
connection uses Wi-Fi,
➤ users can log on to any computer on the network and Bluetooth or satellite to
access their files. connect computers.

51

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 51 03/05/20 1:33 PM


International Computing for Lower Secondary

KEYWORDS
A wide area network (WAN) is a network of networks which
satellite link: a radio
extends over a large geographic area. A WAN is connected using
link between one
a cabled or wireless link. Since they cover a large area, satellite station transmitting
links or fibre optic cable are more likely to be used because of on Earth and another
their capacity to carry data over longer distances. through a satellite
fibre optic cable: a
The internet itself is a WAN, consisting of a global network of cable with a glass or
computers. Perspex core used
to link networks
together; data
transmission is via
Server light signals and
the speed of data
LAN
transmission is very
fast
workstation copper cable: has a
core of copper wires
which is covered in
plastic or rubber;
Server
the wires can be
LAN WAN twisted together;
data transmission
is through the use
of electrical signals;
Server
copper cable is
cheaper than fibre
workstation LAN optic cabling but
the speed of data
transmission is much
slower
communications
protocol: an agreed
e-Shop needs to be connected to the internet, which is a WAN. standard or set of
This is because e-Shop has customers all over the world who rules for sending or
need to be able to order online and communicate with them. receiving data on a
They could not use email, video conferencing, VoIP or other network
communication technology without the internet. e-Shop’s router: a piece of
networking equipment
website is also available via the internet. that shares a network
connection between
Main differences between LANs and WANs devices; it can be
A LAN is spread over a small geographic A WAN is spread over a vast geographic wired or wireless
area, usually one or two buildings. area over countries or the world. and allows a LAN
to connect to the
Computers on a LAN are normally A WAN is a network of networks – these internet
linked together using copper cabling or networks are often linked together using
wireless technology. fibre optic cable or satellite links.

How do WANs and LANs talk to each other?


Computers and networks which communicate with each other
must ‘speak the same language’. A communications protocol is
an agreed standard (or set of rules) for sending and receiving data
on a network. If a computer receives data on a network, it must
support the communications protocol of the sending computer.

52

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 52 27/04/20 6:14 PM


Unit 8.2 Networks and communication: Across the world in an instant

Practice
DID YOU KNOW?

You have been promoted within e-Shop and are now responsible
for global training in the area of digital communication and
networks. e-Shop has asked you to travel across the world to
provide specialist training in a range of new areas.
As part of your new job, e-Shop has asked you to talk to two
new trainee technicians. The technicians are new to the job and
do not know much about networks. Create a presentation for The protocol used on
the internet is called
them which will answer each of the following questions.
Transmission Control
➤ What is a LAN? Protocol / Internet
This section Protocol (TCP/IP). The
➤ What are the advantages of should mention the use of protocol used to transmit
having a LAN? communications technology, its data around a LAN may
➤ What devices does e-Shop importance to e-Shop and the be different. A router
have connected to the LAN? impact on the company if there is connects the LAN to the
no WAN connection. You should internet and allows these
➤ Why does e-Shop need to
also mention the website and two networks, which may
be connected to a WAN? use different protocols,
online selling.
➤ The importance of communications to communicate.
protocols for e-Shop’s business. HTTP means Hypertext
Transfer Protocol. This
Your presentation must include pictures, sound and text to is the protocol used for
explain each of the above. data transfer on the
world wide web.
You can use a presentation tool, such as Microsoft PowerPoint or
Google Slides, or you could create a movie with software such as HTTPS means Hypertext
Transfer Protocol
Windows Movie Maker, with pictures and a voiceover. Secure. This is the
protocol used for secure
communication on the
Checking it out online world wide web, for
example, when credit
card details are being
Learn entered. We can usually
tell when a website uses
To connect to the internet https as there is usually
a padlock symbol beside
you need both hardware the website address.
and software. As well as a
computer, e-Shop needs to
have: DID YOU KNOW?
ISPs can see all of the
➤ web browser software
data you generate when
➤ an internet service you browse the internet.
provider (ISP) They can see the
websites that you visit
➤ a wired or wireless connection and the material that
➤ a hub or router. you view. Over time they
could build up a profile
of your browsing habits.
KEYWORD
internet service provider (ISP): a company who provides users with an What is the name of
internet connection for a subscription fee the ISP you use?

53

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 53 03/05/20 1:34 PM


International Computing for Lower Secondary

A website address or URL is made up of several different parts. DID YOU KNOW?
IPv4 and IPv6 are used to
https://www.amazon.com/gp/help/customer/display.html create IP addresses. IPv4
is displayed in decimal
whereas IPv6 is displayed
Protocol The domain name The folder The web in hexadecimal. IPv6
stored on a domain where the web page was introduced because
name server (DNS) page is located requested IPv4 could not provide
addresses for all the new
When a website address is typed into the browser: devices connecting to the
internet. IPv4 is limited in
➤ The computer sends the request for the web page to the router. the number of addresses
it can represent whereas
➤ The router passes the request to the ISP which looks up the
IPv6 has an almost
domain name on a domain name server (DNS). The DNS unlimited number of
converts the text-based URL (such as www.amazon.com) to addresses available.
a numeric IP address (such as 108.174.10.10). The IP address IPv4 sample address:
describes the location of the server for the website that has 13.243.232.166
been requested. Each dot separates an 8
➤ The IP address is returned to the browser which sends a bit binary number which
is displayed in decimal.
request via the ISP to the particular server identified in the IP So IPv4 is made of four
address for the web page. 8 bit numbers.
➤ The server containing the web page has a folder and file IPv6 sample address:
structure just like on your own computer. The final part of the 2003:0bd7:0000:0000:0
URL contains the details of this folder structure and exactly 000:ff00:0043:6879
where on the server to find the web page. Each semicolon
separates a 16 bit
An internet service provider (ISP) is a company which provides binary number
internet access to businesses or individuals for a fee. This access which is displayed in
is normally provided by connecting a router to the internet via hexadecimal. So IPv6
a copper or fibre optic cable. The ISP can provide a range of is made of eight 16 bit
services such as: numbers.
For more on binary and
➤ a variety of bandwidth options – which means different hexadecimal, see unit 8.1.
download and upload speeds
➤ an email service
KEYWORDS
➤ a security package; this can include protection against
cloud storage: online
hacking, viruses, spyware and identity theft storage space for files
➤ cloud storage facility and documents
➤ a domain hosting service which allows users to upload their
own web pages
Which types of cloud
➤ online and telephone assistance storage do you use?
➤ website filtering and parental controls.
When a user selects an ISP they may need to install the software domain hosting
for that ISP onto their computer. This allows the computer to service: a service
where users can
communicate through a hub or router to an internet file server, upload their own
enabling the user to browse different websites. website and make
it available on the
Internet Service Providers include: CMC Telecom, FPT, Expereo
internet
and Hanoi Telecom.

54

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 54 27/04/20 6:15 PM


Unit 8.2 Networks and communication: Across the world in an instant

Practice KEYWORDS
website filtering:
software which
➤ Find the IP address of a computer. enables websites to
o Use a Windows computer. be allowed or blocked
o Press the Windows Start key to open the start menu. based on their content
parental controls:
o Type cmd and press Enter.
rules, set by parents,
o Type ipconfig/all (this will provide the network card which govern the
settings on your computer). websites that are
o The MAC address and the IPv4 address will be listed. allowed to be viewed
on a device
o Take a photograph or screenshot and compare your result
with another pupil in class.
Give an example of a
➤ Using the internet, find out what a MAC address is.
parental control.
➤ Use your photograph or screen shot and create an electronic
poster which explains what the IPv4 and MAC addresses are.
Hypertext Markup
➤ Email your poster to a friend and ask them to review it to Language (HTML):
ensure it is accurate and error free. the language used to
create web pages
hypertext: clickable
Web browsers links on a web page
meta tags: a coding
statement that
Learn describes some of the
content on the web
e-Shop’s business is supported by the internet and a website. page; this can be used
by search engines
The website design needs to be updated every year. When the
to help identify if
website is updated, e-Shop must test the new version in different the page should be
browsers to make sure it works well. returned in a search
A web browser is software which allows users to view and use
the web pages on the internet. The web pages are usually in
Hypertext Markup Language (HTML) format.
HTML is a programming language used to create web pages.
Web pages can contain hypertext which provides the user
with clickable links to other pages on the web. Sound, video,
animation and graphics can also be embedded in the HTML
web page.
There are many different web browsers available. Some
of the most widely used include Firefox, Google Chrome, You can find more
Safari and Opera. about HTML in
Features of a typical web browser: unit 8.3.
➤ Address bar – the user can enter the web address or URL of
the website they want to visit. Smart address bars will suggest
sites already visited if the user types the first few letters of
the URL. The URL is converted to an IP address as described
above.

55

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 55 27/04/20 6:15 PM


International Computing for Lower Secondary

➤ Search engine – the user can enter text into the search
Using a search
engine box and the search engine will search the internet
engine to search for information
for other web pages containing that text. If a match is
can return many links. You can
found, links to the web pages are displayed. The user reduce the number of search results
can click on these links to visit the relevant websites. by thinking carefully about keywords
Meta tags allow people who create web pages to to include in your search. This
specify special words in the heading of the HTML will refine your search and return
page. These words will help the search engine the most relevant
categorise the page and decide whether or not to include websites.
it in the results for a particular search.
➤ Navigation bar – allows the user to move between the web
pages visited. For example, the user should be able to:
• go back and forward to previous web pages
• refresh a web page
• set a homepage (this is the page that will automatically
load when the browser is opened; the user can return to
this web page at any time by pressing the home button
or icon).
➤ Bookmark option – where the user can keep a list of their
favourite websites by adding the URL to a list. The user can
open a list of bookmarks and go directly to the website.
➤ History button – the user can click on the history button to
see a list of web pages visited; normally, the user can set
the number of days that web addresses are stored in the
history list.
➤ Customisation – most browsers will
allow you to change the appearance
of the browser. For example, the
theme or colour, font size and page
zoom can all be changed.
This is a simple browser showing a
search engine page. The browser can
be customised using the setting feature
shown.
• Browser software can also allow
content to be filtered. For example, content, language and DID YOU KNOW?
whole websites can be filtered. Web browsers can be
• Users can decide if they wish to have certain buttons used to view HTML
showing on the browser, for example, a link to their email, pages whether they are
bookmarks or homepage. online or offline.

• Privacy settings are very important and these can be In 2020, around 65%
of users used Google
customised. For instance, users can turn on private Chrome.
browsing. This means that any websites visited are not
stored in the history list. You may want to stop cookies

56

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 56 27/04/20 6:15 PM


Unit 8.2 Networks and communication: Across the world in an instant

from being installed on the home computer used by


children so that online advertisers can’t track their browsing
habits. The privacy settings on your web browser can be
changed so that cookies are not installed. This setting can
usually be found in the Tools section of a browser.
• Users can add toolbars to the browser, for example, the
Google Toolbar and manage security settings.

Practice

As e-communications manager you want to create a resource for colleagues to help them
understand the key features of a web browser.
Review two different browsers such as Google Chrome and Safari.
List the features that each browser provides and note any differences.
Create a dictionary showing the features of a browser. The dictionary should have images
demonstrating the main features and hyperlinks to sample browsers.

Using technology safely


Learn

Staff at e-Shop spend a lot of time at a


computer. Some staff deal with customer
orders and spend a lot of time looking at
orders online. Other staff are responsible
for updating the website, for example,
changing prices, adding new products and
removing old ones. Without the right advice
on using computers safely, employees in
these roles could develop health problems.
It is important that employers make sure
employees are safe at work.
e-Shop has created a Health and Safety at Work team. The function of the team is to
make staff aware of how to avoid health problems and injuries that can arise because of
prolonged use of computer technology.
The team are meeting with a number of employees who have developed some health
problems. The team intend to observe the employees at work to try to help resolve the
problems. The company doctor, Dr Kecheng, will give advice on how these problems can
be avoided and a leaflet will be created from the information collected.

57

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 57 27/04/20 6:15 PM


International Computing for Lower Secondary

Here are some of the problems the team and Dr Kecheng have seen:

John, a web designer


Symptoms: Sore arms, shoulders and neck. His wrists are also sore.
Diagnosis: RSI – repetitive strain injury, caused when an employee has been using
the same muscle group to perform the same actions over and over again, such as
working at a keyboard all day.
Treatment: Take regular breaks, use an ergonomically designed keyboard and
mouse, Use a wrist rest underneath the keyboard and a foot rest.

Joy, a sales executive


Symptoms: Headaches, blurred vision and worsening eyesight.
It was observed that Joy’s work rate decreased as the day went on.
Diagnosis: Eyestrain.
Treatment: Use on anti-glare screen; make sure the screen has a swivel base to deflect
light; use screens that have adjustable brightness and contrast; have good lighting in
the office; Have regular eye tests.

Min the receptionist


Symptoms: Occasionally she appears to have mobility problems.
Min has been observed to have poor posture while sitting at the computer for prolonged
periods.
Diagnosis: Back pain
Treatment: Use adjustable chairs that allow height adjustment and backrest tilting.
Take regular breaks and regularly exercise affected muscles.
Take training for improving desk posture.

58

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 58 27/04/20 6:15 PM


Unit 8.2 Networks and communication: Across the world in an instant

Practice
Top of screen
➤ The team have created this graphic to help at eye level
staff understand the way in which they
should use their computers to avoid health
problems. This will be used on social media Wrist
support
and the staff area of the website. Forearms
horizontal
➤ Work in a team of four. e-Shop is going Desk about
to tweet the graphic with a message for 70 cm high
employees about their health and safety.
Compose:
Adjustable
o a message for Twitter (less than 280 chair (height,
Footrest
characters) that will accompany the graphic (if required)
back and tilt)
to help ensure employees are safe at work
o an email to the Managing Director which
asks him to review the staff workstations
to make sure they are safe for staff to use; your email should explain some of the
problems that can be caused if workstation design is not right.

Cyber security

Learn
KEYWORDS
cyber crime: a
Cyber crime malicious attack on a
Cyber crime is the use computer system
computers to commit an malware: software
designed to damage
act which is against the
a computer system or
law. e-Shop has a global its data
business which would be
badly affected if it was a
victim of cyber crime. So,
it has strict rules relating
to the protection of its systems and data.
Despite these rules, on a number of occasions there have
been cyber attacks on the company. The network managers
(responsible for all the devices and software on the network
and ensuring that it runs without problems) across a number of
countries met via video conference to discuss the issues. The
following problems were identified.

Malware
A number of customers reported that malware had been
downloaded from emails received from e-Shop. Malware is
malicious software which is unintentionally downloaded onto
a computer via an email or portable storage device like a
USB drive. Malware is a generic term for different types of

59

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 59 03/05/20 1:38 PM


International Computing for Lower Secondary

KEYWORDS
malicious software which includes viruses, worms, spyware and
keyloggers. virus: a program
which gains access
➤ A virus is a program which has been designed to damage a to a computer and
computer when executed. seeks to damage the
computer system or
➤ A worm is a virus which replicates itself so that it can spread
collect data
to other computers. A worm can arrive as a spam email
message. The process of replicating itself will use system
resources and slow the computer or network down. Tell a partner about a
time when one of your
➤ Spyware is software designed to take information from a devices got a virus.
computer without the knowledge of the user. The spyware
software will pass the information on. worm: a malicious
➤ A keylogger is a program which logs every keystroke made on software application
a computer. In the hands of a hacker, it could be used to steal which spreads across
passwords and PINs. computer networks;
typically used when
Phishing an email attachment
is opened and the
Customers also reported receiving phishing emails asking them program is activated
to update their personal details using a hyperlink. Phishing emails spyware: software that
look to be from a reliable source but when users click on the gathers information
links they are taken to fake websites. If they enter their details about a person or
on the fake website (such as a password) then the criminals gain organisation without
their permission. The
access to their real accounts and all their personal details. software is usually
downloaded without
Pharming the user’s knowledge
Customers have also been subjected to pharming where their keylogger: a malicious
web browsers have been redirected to fraudulent websites software application
instead of the real e-Shop website. which collects the
keystrokes that a
Spyware person is typing
typically used to
Staff at a number of locations have detected spyware on their find out peoples’
computer. The spyware was downloaded without their knowledge passwords
and used an internet connection to collect information about phishing: sending
their online activity. Staff were concerned that the spyware could fake emails to capture
have collected data such as credit card numbers. personal details
pharming: redirecting
DDoS users to fake websites
to capture personal
Network managers at two locations have reported disrupted
details
connections to their web servers. They believe this to be a
distributed denial of
distributed denial of service (DDoS) which is a malicious attack service (DDoS): an
on a network that can prevent users from logging on to access attack on a network
their data. When you hear about a website being ‘brought down’ that can prevent users
it is usually because it has suffered a DDoS attack. Hackers use from logging on to
access their data
malware to generate millions of bogus requests for access to
the website. The aim of the attack is to stop the website from
working by flooding it with more network traffic than it can
handle. The website will eventually crash.

60

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 60 27/04/20 6:16 PM


Unit 8.2 Networks and communication: Across the world in an instant

KEYWORDS
Data security
data security:
The network managers have identified three areas where the protecting data
company could improve in terms of data security. encryption: a process
which scrambles data
Encryption so that it cannot be
Data which is being transmitted across a WAN or a LAN could be read by unauthorised
users
intercepted and read by unauthorised users. To prevent this, data
encrypted: data
can be encrypted. Encryption is the process of encoding data
encoded in some way
which is to be sent across a network, making that data unreadable to protect it
to anyone who intercepts it. Only a user with the encryption key encryption key: the
software can read the data when it arrives at its destination. key which will decode
the data so that it can
Encrypting data whilst it is travelling on the network is one way of be read by a receiving
keeping data secure. Data can also be stored in encrypted form. computer
This means that users can only read the data if they have access firewall: hardware
to the special software which will decrypt or decode the data. or software which
monitors and filters
data entering and
Algorithmic thinking leaving the network
hackers: individuals
An encryption key is needed to decode messages who try to gain
received. Using the key below, decode this message: unauthorised access
to computer systems
to damage them or
GPETARVKPI FCVC KU HWP steal data
spam: email that is
LETTER A B C D E F G H I J K L M sent as part of a large
CODE C D E F G H I J K L M N O set of messages; the
email is not wanted by
the receiver
LETTER N O P Q R S T U V W X Y Z
CODE P Q R S T U V W X Y Z A B
Give an example of
some spam you have
Create your own encryption key and use it to create a recently received.
message. Ask a friend to decode the message using the
key you have created.

Firewalls
A firewall can be a hardware
device or a software program. It
monitors and filters data entering
and leaving a network. It uses
security settings or rules which
block data which does not comply
with the organisation’s security
policy. It can prevent:
➤ hackers from entering the network via the internet
➤ viruses and spam from entering the network via the internet

61

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 61 27/04/20 6:16 PM


International Computing for Lower Secondary

KEYWORD
➤ users/computers within the network from uploading data onto
levels of access:
the internet.
limiting the activities
Levels of access different users can
perform on the
Another way of keeping the network secure is to limit the computer system,
based on their role in
activities different users can perform by allocating levels
the organisation
of access. For example sales staff, managers and network
managers have different levels of access.
A sales person can: Practice
➤ access software and the internet
➤ change their password, and the content and location of their Produce an
user files infographic which
➤ connect and use printers portable storage devices. illustrates the
main threats to
A manager can do everything that a sales person can and also:
online users and
➤ give users printer credits the methods
➤ reset user passwords available to help
➤ monitor user activity using special software secure online
➤ set up shared folders for staff to use.
communications.

The system manager can do everything a sales person and


manager can do and also:
➤ set up new users and delete or disable existing users
➤ change the amount of disk storage that each user is allocated
➤ copy files between users
➤ allocate network resources such as printers
➤ connect new devices to the network
➤ install software.

Go further

e-Shop staff need to know about the problems that could arise if email is not used
properly. You have been asked by the Managing Director to try to find out how much
staff know about email.
◆ Create a phishing email which you will send to all staff.
o The email should have a suitable subject which will trick staff into thinking it is a
genuine email.
o The email should have an attachment containing incorrect information about the
company.
◆ Create a pharming email which you will send to all staff.
o The email should contain a message which redirects all staff to
www.hoddereducation.com – however the staff must not realise that they are being
redirected there.

62

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 62 27/04/20 6:16 PM


Unit 8.2 Networks and communication: Across the world in an instant

◆ Create a final email explaining to staff what pharming and phishing emails are, and why
they should not respond to emails that ask for personal details.
Create a table of information for a photo that you have stored. Use these headings:

File name File type File size  dditional data provided by the
A Description of the image
photo, such as location data

◆ How could your friend make use of the data above?


◆ How could a business like e-Shop make use of the data above?
◆ How does this picture contribute to your digital footprint?
Open the document called networkdata.docx, provided by your teacher. Complete the
table so that you have information on the hardware and software components in your
school’s computer system and how they communicate with each other. Include an image
of the device.
Give your table to a friend to review.
You have been called to an interview for the Network Manager’s job at your school. Your
friend will interview you.
The interview will last five minutes and your friend must ask you five questions about the
information you have collected in your table.
At the end of the interview discuss whether or not you should get the job and why.

Digital data
Challenge yourself
Data in a computer is represented in binary format. As you know, a bit is a single binary
digit which can have a value of 1 or 0. Since there are only two values, the binary system
counts using base 2. (We normally count using base 10 as there are ten digits 0–9.)
Counting using base 2 means that we use powers of two. For example:
210 29 28 27 26 25 24 23 22 21 20
Base 10 value 1024 512 256 128 64 32 16 8 4 2 0

Use a calculator to verify that the decimal values above are correct.
A byte is made up of 8 bits.
8 bits = 1 byte
1 0 0 1 1 0 1 1

A byte can represent a single character such as the letter ‘H’.


1 kilobyte (kB) = 103 bytes = 1000 bytes.

63

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 63 27/04/20 6:16 PM


International Computing for Lower Secondary

1 megabyte (MB) = 1000 kB


1 gigabyte (GB) = 1000 MB
Computer storage and memory is measured in MB and GB.
➤ Calculate the amount of storage needed to store a file with 1 million characters in it.
Give your answer in kB.
➤ How much space will be left on a 1 GB disk if a user stores files which take up 20 000 kB?
➤ How many bits are there in 10 kilobytes?
➤ 1 terabyte is the next largest unit after gigabyte. Can you guess how many gigabytes
are in a terabyte? Create a graphic in the shape of a triangle which shows the units of
storage starting with 1 bit at the top of the triangle moving down to 1 terabyte.
➤ Examine a file which you have stored on your computer system. Calculate the number
of bits stored in the file.
Data transfer speeds
The names and abbreviations for numbers of bytes can be confused with those used for bits.
➤ When referring to bits we use a lower-case ‘b’
➤ When referring to bytes we use an upper-case ‘B’

As one byte is made up of eight bits, the difference can be significant.


For example, if a broadband internet connection is advertised with a download speed of
5.0 Mbps, its speed is 5.0 megabits per second.
To convert the value to megabytes per second we must divide by 8.
So the internet connection speed is 0.625 megabytes per second (which would be
abbreviated as 0.625 MBps).
You need to look carefully at these values when comparing internet connection speeds.

Pattern recognition
Data transfer speeds are normally measured in bits per second not bytes per second but
the same prefixes are used; for example,
1 kilobit (kbps) = 1000 bits per second
1 megabit (Mbps) = 1 000 000 bits per second or 1000 kbps
1 gigabit (Gbps) = 1 000 000 000 bits per second or 1000 Mbps
✪ If an internet connection is advertised as having a speed of 1.5 MBps what is its speed in
Mbps?
✪ Create a poster entitled ‘Gigabit or Gigabyte?’ and explain the difference between the two
units. Your poster should include an explanation of:
o the terms bit and byte and how they relate to each other
o the difference between gigabit and gigabyte using the correct abbreviations
o what gigabit and gigabyte are used for in computer systems.

64

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 64 27/04/20 6:16 PM


Unit 8.2 Networks and communication: Across the world in an instant

Final project
WonderLife Cruises is a new luxury cruise company. The company has six ships which
rank among the largest in the world. The company intends to make extensive use of
digital communications systems for business purposes. Before the company opened,
the owner had a state of the art website constructed. The website will be used to sell
cruises and there will be a section where staff can log on to find out information.
Your challenge, as an e-communications expert, is to provide advice about the use of
communication tools within the company.
➤ Create a report or presentation with three sections. Each section should contain the
following information.
● Section 1: The use of email in the workplace
This section should:
● state how professional emails should be written
● explain phishing and pharming
● explain why employees should be vigilant when reading emails containing
attachments or requests for personal information.
● Section 2: The advantages of using social media in business
This section should:
● explain about the data that is captured about customers on social media
● suggest how the company could use this data
● recommend two social media apps that would be suitable for the company
to use.
● Section 3: The equipment required for video conferencing
This section should:
● list the equipment required for video conferencing
● explain how bandwidth can affect video conferencing
● explain how the company could use the technology
● explain the benefits of video conferencing to the company and to the
environment.
Your presentation or report could make use of hyperlinks from a main page to each
of the sections above.
➤ You have been asked to speak to the staff on board the cruise ships about cyber
security. In groups of four, discuss the cyber security issues that may occur for the
company. You should include information about:
● attack from malware
● attack from hackers
● how encryption could help protect customer data
● how encryption could be used, using a simple example.
At the end of your discussion, create a list of potential cyber security threats to
WonderLife Cruises if they make use of digital communications.

65

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 65 27/04/20 6:16 PM


International Computing for Lower Secondary

➤ Use the list of threats created in the discussion above to make a list of measures that
the company can take to prevent breaches of security. For each threat you have
mentioned you must include a measure which will protect the company.
➤ Add this new section to your report or presentation.
➤ WonderLife Cruises wants to design a healthy work space for the captain of the
cruise ship. Draw a simple block diagram showing how his desk should be arranged.
Include instructions to help the company organise his work space.

Evaluation
➤ Read your report and ensure that it is complete by ensuring
that you have included all of the detail required above.
➤ The purpose of your report or presentation was to provide
advice on the use of digital communications to the company.
The members of staff must understand the challenges
associated with using things like email and social media.
➤ Prepare a typed set of questions that you would ask someone
to ensure they understood the messages in your report or
presentation. Your questions should be made up of:
o one question about Section 1
o two questions about Section 2
o one question about Section 3
o two questions about cyber security threats and
measures.
➤ Give a verbal summary of your report to a group of four
classmates.
➤ Ask your classmates to complete the six questions.
➤ Review the answers to the questions. Do you think your
classmates understood the summary? Look at their answers
and comment on:
o the technical information they have include
o the accuracy of the information they have provided.
➤ Was your report effective in delivering the message?

66

481992_U2_Int_Com_Low_Sec_SB_038-066.indd 66 27/04/20 6:16 PM


Unit HTML and CSS: Getting
8.3 your head straight
The website www.
About HTML and CSS csszengarden.com lets you
HTML and CSS are used to build websites and web-based applications see the impact changing CSS
can have on the look and feel
such as online games, movie streaming applications or online document
of an HTML document. With
editing tools. Website developers create professional, interactive web your class examine the CSS
pages using a HTML and CSS. Once an HTML document is developed designs available on CSS Zen
it can be viewed using a web browser application such as Internet Garden.
Explorer or Opera. Developers use HTML to add content to their documents
and CSS to add style and consistency to a website using templates and
KEYWORDS
master documents. CSS also helps developers change the look and feel of
CSS (Cascading
an HTML document so that it can be tailored to different audiences and Stylesheets): the
cultures around the world. language used to
describe how content on
Documents and web pages on the internet are made up from HTML a web page should be
elements created using tags. Most HTML tags have an opening and displayed in the browser
closing tag with content placed in between. The tags tell the web browser window
website developers:
how to display the content on the screen. For example: individuals or groups of
<h1>will display text in the browser window like this</h1> individuals responsible
for the end-to-end
<h6>will display text in the browser window like this</h6> coding of websites
interactive web page:
HTML tags can be used to add text, images, video and sound to web pages. a web page containing
content the user
CSS can be used to change the colour, font and position of text and can engage with, for
images on a web page. It is the language used by developers to make example through the
use of buttons to make
sure their applications can be viewed on various screen sizes, such as selections, including
laptops, mobile phones or tablets. videos and sounds for the
user to play, or games for
In this unit you will learn: the user to play
➜ how to use storyboarding and structure diagrams to plan website web browser application:
a software package used
content to view website content
➜ the importance of using templates HTML elements: the
➜ how to present text in list and table format using HTML opening tag, closing tag
and content to be added
➜ the importance of incorporating accessibility elements into website
to an HTML document;
design and development for example, <p>This is
➜ how to use CSS to amend the presentation of content on an HTML a paragraph</p> is an
HTML element
document
tags: hidden key words
➜ that CSS can be part of an HTML document or its own separate in a web page which
file and the advantages/disadvantages of each of these describe the content
approaches. to be displayed in the
browser window; for
example, <p> is an
opening tag which is used
KEYWORD to describe a paragraph,
accessibility: providing support for the individual needs of all users, for example </p> is the closing tag for
by including audio output of content for users with visual difficulties the paragraph

67

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 67 27/04/20 6:17 PM


International Computing for Lower Secondary

SCENARIO KEYWORDS
Alex, the founder of a new local charity called Getting Your Head homepage: the
start-up page of a
Straight has asked you to create a new website for the charity. Alex website, the page that
wants to use the website to help raise awareness among young people loads first when the
and adults about the importance of maintaining good mental health. website is displayed in
The site should include advice on taking care of yourself and some tips a web browser

on managing stress.
Alex has said the website should include the following. Describe to a partner
a homepage you like.
• A homepage which includes some information about what is
meant by mental health.
podcast: a digital
• Two additional pages related to:
audio file that is
• taking care of yourself made available on
• coping with stress. the internet and can
• At least one podcast which offers advice on mental health. be listened to online
or downloaded to a
• Links to additional websites which can offer help to users. computer
• A direct email link to the organisation’s email address,
[email protected]
Describe a podcast
• A form which can be used to input This address is fictional.
you have recently
details to sign up for a newsletter If you do need advice on
listened to.
mindfulness or any of the
which is sent out regularly by the
other issues brought up in
organisation. this unit of work, please DID YOU KNOW?
• The website should be easy to use speak to a trusted staff Different browsers
(user friendly) and should include member, parent or other have different ways of
special features to provide accessibility adult. handling CSS styles.
for users with visual impairments. A web page using CSS
might look slightly
• The website should be professional and all web pages should look
different when opened
the same. using the web browser
Alex has also asked for two versions of the website, one aimed at Internet Explorer than
it would if opened using
young people and one aimed at adults. the Opera web browser.
Before you agree to develop the web page for Alex, you have told
him that you would like to spend some time developing new skills in a
language called CSS which will help you give him the professional and
consistent web page he wants for the charity.

68

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 68 29/04/20 8:57 PM


Unit 8.3 HTML and CSS: Getting your head straight

Do you remember?
KEYWORDS
Before starting this unit, you should be able to: navigational
structure: the pathway
✔ use a text editor to create a HTML documents
the user can follow
✔ edit and preview HTML documents when visiting the
✔ use paragraph and break tags to break up the displayed text in various web pages on
a website
an HTML document
structure diagram:
✔ use the style tag to incorporate basic CSS into HTML tags (inline a diagram illustrating
CSS) to amend the colour of text displayed in an HTML document the pathway through
the pages of a website
✔ insert images into HTML documents and amend the size of an
storyboard: a set
image to be displayed in a browser window
of line drawings
✔ insert sound and video files into HTML documents which provide a
✔ create internal and external hyperlinks in HTML documents. basic outline of the
content of pages of an
application
Planning websites
Draw a storyboard of
the steps it takes for
Learn you to do a common
function on a social
Before developing a website such as this one it is important that media application you
frequently use.
you consider the navigational structure and the content of the
application.
Structure diagrams can be used to plan how users can navigate
between different pages of a website and storyboards can be
used to plan the content of individual pages.

The homepage of a
Practice website (the first page
which is to be loaded into
After some discussion with Alex you have agreed on the the browser window)
following design for the website’s structure and index page. should be saved as
index.html.
(index.html)
Homepage

Taking care Coping with


of yourself stress

69

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 69 27/04/20 6:17 PM


International Computing for Lower Secondary

Storyboard for index.html


Getting Your Head Straight Logo
Hyperlink to Hyperlink to Taking Hyperlink to Hyperlink to
Home care of yourself Coping with stress Contact us
Mental Health (heading)
Mental health includes our emotional, psychological and social well-being. It
can affect how we think and feel and how we get on with others.
Mental health is just as important as physical health.
It is tough to talk about sometimes, but talking helps you to cope with problems.
Help yourself, stay healthy with:
• Exercise
• Balanced diet
• The right amount of sleep
• Talking about problems
• Learning to say no (don’t be pressurised into doing anything you don’t
want to do)
Click below for more information on:
Taking care of yourself Coping with stress
Image of young person using Image of young person working
mobile device at a desk

You must now produce a storyboard for two more pages of the website: Taking care of
yourself, and Coping with stress.
The storyboard for each web page should include:
➤ the organisation’s logo
➤ a page title
➤ links to all other web pages in the website
➤ an indication of where the images will be located, and a description of the images
➤ an indication of where the text will be located, and what the text will say.
You should also:
➤ add a table to the bottom of the Taking care of yourself page use the table to display
hyperlinks to websites of at least two organisations that are local to you and which
support mental health
➤ include a video at the bottom of the Coping with stress page (the video can be
downloaded from the internet and saved in your asset folder or it may be included as a
link to another website).

70

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 70 27/04/20 6:17 PM


Unit 8.3 HTML and CSS: Getting your head straight

Think carefully about where the logo, hyperlinks, headings, text and images are placed.
Use the same layout on the storyboard for each of your two new web pages. Consistent
layout keeps web pages professional looking and easier to use.
Once the storyboards are complete you will need to:
➤ search for relevant websites on taking care of yourself and coping with stress
➤ use the information you have found to help you write two short paragraphs on
each topic.

Generalisation
You can use the layout for the homepage as the basis for
the layout of the two additional pages. This is an example of
generalisation.

Decomposition

When searching for websites on taking care of yourself


and coping with stress, break each topic down and Always remember
decide on the keywords for internet searches. You to attribute credit to data,
need to search for the following assets and information images or videos created by
for each of your web pages. someone else when you are
using them. You can do this
✪ Information that you can rewrite in your own words. by including the address of
(You will need to write one paragraph for each page/ the originating website or the
topic.) original author’s name.
✪ Relevant images for each web page.
✪ Hyperlinks to the websites of at least
two organisations which support mental health.
✪ A short video about coping with stress.
You should source the video from the Save any images
internet; we will look later at alternative and or videos you wish to use
ways of linking the video into your on your assets folder inside
website. the MyWeb folder. This folder
will be provided by your
teacher. You will use
these later.

71

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 71 27/04/20 6:17 PM


International Computing for Lower Secondary

HTML: paragraphs and lists


Learn
In HTML you use the
Web pages do not only contain text and images. They will <p> </p> tag to insert
often contain content displayed in lists and tables. paragraphs of text and
use <br> to add a line
Lists can be shown in ordered or unordered format on
break without starting a
web pages using HTML. Styles can also be applied to lists.
new paragraph.
Example of an unordered list: Example of an ordered list:
<ul> <ol>
Style can be
<li>Exercise</li> <li>Exercise</li>
applied to ordered and
<li>Balanced diet</li> <li>Balanced diet</li> unordered lists. For example,
<li>Talking about <li>Talking about unordered lists can be displayed
problems</li> problems</li> using circle, square or disc markers.
<li>Learn to say no</li> <li>Learn to say no</li> Ordered lists can be displayed
</ul> </ol> as numbers, letters or Roman
● Exercise 1. Exercise numerals. These are known
Balanced diet as Type ‘1’, ‘a’,

2. Balanced diet
● Talking about problems ‘A’, ‘i’ or Type ‘I’.
3. Talking about problems
● Learn to say no
4. Learn to say no
Example of a styled unordered list: Example of a styled unordered list:
KEYWORDS
<ul style = “list-style- <ol type=”i”>
type: square”> <li>Exercise</li>
ordered list: a list
where each item on
<li>Exercise</li> <li>Balanced diet</li> the list is given a place
<li>Balanced diet</li> <li>Talking about problems</li> value such as ‘1’, ‘a’, ‘A’,
<li>Talking about <li>Learn to say no</li> ‘i’ or ‘I’
problems</li> unordered list: a list
</ol>
<li>Learn to say no</li> of text appearing
</ul> on a web page with
i. Exercise no special order or
o Exercise
ii. Balanced diet sequence
o Balanced diet Roman numerals: for
iii. Talking about problems
o Talking about problems example, i, ii, iii, iv
iv. Learn to say no
o Learn to say no

Practice

Now that you are familiar with adding lists using HTML, Alex would like to see a first draft
of the index.html page. He has asked you to put this together for him
based on the Home Page storyboard in the practice panel on page 70.
All work completed
Your teacher will provide you with a folder called MyWeb. throughout this
chapter should be
This folder contains a file called index.html. This file will contain
saved to the MyWeb
some basic HTML which can then be used to build the index page folder.
for the Getting Your Head Straight website. You will also be provided

72

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 72 27/04/20 6:17 PM


Unit 8.3 HTML and CSS: Getting your head straight

with a folder called assets. This folder will contain some images
you may find useful when creating your website.
You will use an application called Notepad++ to produce the
HTML needed in the production of the website for this project.
Using the file index.html and what you know already about
HTML and lists, edit the HTML in the file index.html provided
by your teacher so that it contains all of the text and images
described in the storyboard for index.html.
➤ Open the folder called MyWeb.
➤ Right click on the file called index.html.
➤ Select Edit with Notepad++.
➤ Edit the HTML provided to ensure
that when it is displayed as a web
page the index.html page contains
all of the information shown by
the storyboard.

Throughout this
Abstraction and generalisation chapter you will use an
application called Notepad++
The illustration and example shown below provides some hints. to create HTML pages.
This application can be
✪ Use abstraction to identify the tags you will not need.
downloaded from https://
✪ Using generalisation and your previous experience of HTML, notepad-plus-plus.org/
select the correct tags from those provided below to add the rest downloads
of the content to the web page.
Use the <title> </title> tag to add text which will describe the web page
<b> </b> in the web browser window

<ul> </ul>
<li> </li>

<p> </p>
Think carefully about how many paragraphs and line breaks you
will add here for the main text in your website.
<br>
Add your list about keeping yourself healthy here.

<i> </i>
Do you need another paragraph of text before the images and hyperlinks
to the two additional web pages?
<u> </u>
Combine the HTML tags shown below to add two appropriate images
<ol></ol> to the bottom of your web page. The images you need are
<li> </li> stored in the assets folder provided by your teacher.
• Taking care of yourself
• Coping with stress
<a href="url">link text</a>

<img src>= “ “ alt= “ “ style = “width:_____,height:_____”

73

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 73 03/05/20 8:31 PM


International Computing for Lower Secondary

✪ Save index.html
This example web page and HTML code will also help you remember HTML syntax for the
tags shown.

Look also
at the examples
shown on page 72
on creating
lists using HTML.

HTML: tables and comments


Learn

Tables are an excellent way of providing information in an easy to read and organised
way. They normally contain table headers and cells that make up rows and columns. We
can use HTML to add tables to web pages. When using HTML to describe a table it is
important to plan ahead and think carefully about how many rows and columns the table
will have, the headers for each column and the data that will be in each cell in the table.

table headers KEYWORDS


column
table header: data
used to describe the
contents of each
Organisation Name Contact Telephone Number column in an HTML
table
cell Childline 0800 1111 cell: single square or
rectangle in a table
row Young Minds 08088025544 used to contain an
item of data or a
table header
HTML uses the following tags to describe a table which is
comments: text used
being added to a web page. to explain your code;
➤ <table> </table> tag defines the start and end of the table they can be seen by
➤ <tr> </tr> defines the start and end of a table row anyone viewing the
HTML code but are
➤ <th> </th> identifies a table header not displayed in the
➤ <td> </td> describes the data being added to a cell in a table browser window

74

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 74 27/04/20 6:17 PM


Unit 8.3 HTML and CSS: Getting your head straight

The code used to create the table shown on the previous page would be:

HTML code produced to create tables and other website content can become very long
and difficult to understand.
You may have noticed that some of the text shown in the HTML example on page 74 was
coloured green. These lines of text represented comments. Coders use comments to help
explain what their code is doing. This can help other people to understand it. It is also
helpful if they need to make changes to the code in the future. Comments in HTML are
written in between the <!-- --> tags
<!--this is how a comment might look in HTML -->

Practice

Before you can create the last two web pages of the Getting Your Head Straight website, we
should check that you understand tables.
Your teacher will provide you with a file called tabletest.html to allow you to complete
this task.
➤ Open Notepad++.
➤ Open the file called index.html.
➤ Edit the HTML in index.html to include the table definition shown (below left). This will
create the table shown (below right) in a browser.

75

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 75 27/04/20 6:17 PM


International Computing for Lower Secondary

➤ Save index.html and preview it in a browser window to ensure you have entered your
code correctly.
➤ Add comments to show where the table definition starts and ends in the HTML file.
➤ Add comments to show where each row in the table begins and ends.
➤ Add comments next to the row headers and the data in the tables.
➤ Add another row to the table to include the name and telephone number of a local
organisation which provides mental health support to young people.
➤ Save index.html and close Notepad++.
The table produced by the HTML does not look professional. With a friend, discuss how you
might improve the appearance of this table.

HTML: CSS style tags


KEYWORDS
Learn style information:
information relating
to how an item will be
Developers can add style information to an HTML document by presented on an HTML
adding a style tag (<style> </style>) and CSS style rules to document when it is
the HTML document. opened in a browser
window
Some of the CSS styles which can be added to a table in an HTML style tag: used to
document include border, padding, text-align, border-spacing and contain information
border-collapse. or rules which will
define how items
➤ Border: if you do not define a border for your table it is
described using HTML
displayed without borders. The border can be specified in terms will be displayed in the
of pixels; for example, the border in the example shown on the browser window
next page is 1 pixel wide, it is a solid line and coloured black. CSS style rules: the
➤ Padding: provides spacing between the contents of the cell actual rules used to
define how items
and the cell border. Cell padding is defined in pixels. In the
described using HTML
example shown there is a space of at least 15 pixels between will be displayed in the
the borders and any content appearing in each table cell. browser window

76

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 76 27/04/20 6:17 PM


Unit 8.3 HTML and CSS: Getting your head straight

➤ Text-align: defines where in the cell the text will be placed. Table headings will
automatically display as bold and centred and data will automatically be left aligned. You
can alter the way text is displayed in each cell by using the text-align style. The text-align
style allows you to align text to the left, right, centre, or justify (the cell content will be
stretched so the lines are equal in width).
➤ Border-spacing: provides a space between the cells in the table.

In this example the


th (table heading)
and td (table data)
have both been
defined as having
borders.

➤ Border-collapse: collapse reduces multiple borders to a single border. You can try
adding and removing border-collapse to your table when you complete the practice
task that follows.

Practice

Add some CSS to your HTML to improve how the table appears.
➤ Open Notepad++.
➤ Open index.html.
➤ Add the style tag in between the opening and closing head tag as shown below.

The head tag in an HTML


document can be used to store
metadata (data about data). Adding the
style tag to the <head> tag at the start Adding a style
of an HTML document is an example of definition to the <head>
metadata: the data placed in the style tag of an HTML
tag is used to describe how the content document is an example
defined by the HTML tags on this web of internal CSS.
page will appear in when it is
displayed in a browser window.

77

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 77 27/04/20 6:17 PM


International Computing for Lower Secondary

➤ Edit the content of the style tags as shown below.

You can experiment with:


alternative pixel widths for your
table borders; different border styles
(for example, instead of ‘solid’, use
‘dotted’ or ‘double’ to see how this
changes the appearance of the
table); change the colour of the
border (for example, try red or blue
instead of black).

➤ Save index.html file and preview Try changing


the file in a browser window. border, padding
With a friend, discuss how and border-

{
this has changed the appearance spacing to see
of your table. how this impacts
➤ Try expanding the style tag on the way the
as shown on the right. table looks.
Try removing border-
collapse to see how this Add each style one at a
alters the way the table looks. time, save index.html and
preview your change in
CSS can also be used to specify how much of the web page the browser window before
you would like your table to take up when it is displayed in moving on to add and
the browser. experiment with each
To specify the width of a table using CSS, use the width property. new style.
➤ change your table tag in the main body of your HTML so it now reads
<table width=“100%”>.
➤ Save your HTML document and then preview it in the browser window.
➤ How has the table display changed?
➤ When you use percentages to determine the size of an Adding CSS to the
element you are telling the browser how much of the screen HTML tags in the <body>
you want that element of the screen to fill. If you change section of an HTML
the size of your browser window the element will change document is an example
size also. of inline CSS.
➤ Once you are happy with how your table looks, save index.html
and preview the file in a browser window.
➤ Once you have finished experimenting with your style definitions save index.html.

DID YOU KNOW?


KEYWORDS HTML is used to define
internal CSS: the style definition would be included as part of the <head> the content and
</head> tag at the start of an HTML document structure of a web page;
inline CSS: CSS which is applied to a single element in the <body> section of CSS defines how that
an HTML document content is presented.

78

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 78 29/04/20 9:07 PM


Unit 8.3 HTML and CSS: Getting your head straight

HTML and CSS: divs and styles

Learn

When you add content to your web pages using HTML it is important that you think
about the layout of the page and the sections it is divided into.
Website developers often use formatting or colour to distinguish different sections of a
web page.

{
Banner containing
company name and
logo – light blue

{ Navigation bar
– dark blue

Main content
area – white

Website developers use a tag called the division tag (or div tag) <div> </div> to split
their web page into sections. You can then use HTML and CSS to make changes to any
content contained inside a set of div tags. Any content or elements which are outside
that set of div tags will not be changed.
CSS allows you to use style attributes to change how an HTML element will display on
the screen. A CSS style can be applied to all of those elements inside a <div> tag at the
same time.
In the example below you can see how index.html has been broken into sections or
<divs>. There are four <divs>.
➤ The first <div> will contain the page header.
➤ The second <div> contains the navigation section for the page.
➤ The third <div> contains the main page content (text and images).
➤ The fourth <div> contains a table of information.

79

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 79 27/04/20 6:18 PM


International Computing for Lower Secondary

The example above also shows how different style attributes were applied to each of the
<divs>.
You can apply CSS styles to any HTML tag as long as you remember the syntax rules: all
CSS elements need to have the following.
<[html tag] style="background-color: red;">

The style CSS property is the CSS value is the A semi-colon (;) is used to
attribute thing you want to thing you want mark the end of the style
change; for example, to change it to; definition or to separate
background-color for example, red multiple definitions

Quotation marks ("") are used


to show the start and end of A colon (:) is used to divide
the list of style definitions the property and the value

KEYWORDS
div tag: a tag <div> </div> used to group sections of HTML elements together for further formatting, for
example, using CSS
attribute: used to define how the text, images and other content is to be displayed on a web page,
normally added to the opening tag of an element; for example, <p align = ‘left’>This is left aligned</p>
syntax rules: the rules of a programming language which determine how its instructions are written
CSS property: the attribute you want to change using CSS
CSS value: the new value you wish to assign to the property identified in a CSS style tag

80

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 80 27/04/20 6:18 PM


Unit 8.3 HTML and CSS: Getting your head straight

Practice

Style tags can be used to contain more than one style attribute. Let us look at how you
can add multiple style attributes to a single style tag.
Your teacher will give you a copy of a file called usingdivs.html to allow you to complete
this task.
➤ Open Notepad++.
➤ Open the file called usingdivs.html.
➤ Amend the code in usingdivs.html, adding the property and value “display:
inline-block”, so that it reads:
<div style=”background-color: silver; height: 100px; width:
100%; display: inline-block”>
<h1>Getting help from others</h1>
</div>

➤ Save usingdivs.html and preview the file in a browser window.


Do you notice anything different now that you have added Do you notice now
the “display: inline-block” style? how the gap has been
➤ Amend the style definition for the paragraph which removed between the
reads ‘My navigation links will go here’ to include first and second
“display: inline-block”. colour blocks?
➤ Save usingdivs.html again and preview the file in a
browser window.

Generalisation

Use your knowledge of HTML to describe how the CSS property


values shown below would amend the display of usingdivs.html.
Complete the table below to describe what each CSS property
does. Your teacher will give you a file called Describing CSS
Properties. It contains a copy of this table for you to complete.

CSS Property Description Example values


background-color red; yellow; green;
color red; yellow; green;
height 120px; 120%
width 120px; 120%
border 2px solid black;
float left; right; none
font-size 12px; 12pt;
text-align left; right; centre;
margin 5px;

81

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 81 27/04/20 6:18 PM


International Computing for Lower Secondary

Algorithmic thinking

Once you are confident using and applying multiple styles to


each <div> section you can now amend your index.html file to
apply additional styles to each div.
Use what you have learned about combining HTML and CSS to
experiment with applying some of the CSS properties above to
the content of the file called usingdivs.html; for example:
<div style=“background-color: yellow;”>
<p> My navigation links will go here</p> Here we have used the
</div> property background-
color: to separate the
navigation section of this web
<div style=“background-color: silver;”>
page from the section which
<p> My page content will go here</p> will be used to display the
</div> main web page content.

This lets you see the changes


made by each new CSS
property you have added but
• Try adding multiple CSS properties to the same div. also makes it easier to debug
• Remember to save and preview the file in the your code if you have made an
browser window each time you add a new CSS error. If you have only added
property. one new property you only
need to look at it to check for
• When you are happy with the way your index.html page errors!
looks when you preview it in a browser window, close
index.html and close Notepad++.

82

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 82 27/04/20 6:18 PM


Unit 8.3 HTML and CSS: Getting your head straight

CSS: classes and styles

Learn

CSS provides developers with some very effective ways of


changing the presentation of an HTML document. In the previous
task you saw how the CSS style attribute can be used to contain
more than one CSS property.
The HTML needed to produce even the simplest of web
pages can become very long and complicated, especially if it
contains inline CSS code. This can make the code very difficult
to interpret, especially if you need to make changes to it at a
later stage.

KEYWORD
class attribute: an
attribute which can be
One of the ways developers can help make the code easier to used to define styles
understand is by using the class attribute. for other elements
with the same name
Earlier in this chapter you looked at adding a style definition to the so they all have the
<head> section of a web page. same style

83

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 83 27/04/20 6:18 PM


International Computing for Lower Secondary

KEYWORDS
For example, you used the border: attribute to add a solid black
internal style: CSS
line border around the table. This was an example of what is
definitions which have
known as an internal style. By adding the style to the <head> been included in the
tag of the web page you were also adding metadata to the <head> tags of an
HTML document. HTML document
metadata: data
When we first added style definitions to our table we created an about other data; for
internal style definition as shown on lines 5-12 in the example below. example, the use of
style definitions in an
The example creates a new class called .header. The .header
HTML document used
class now includes all of the style definitions for the page header to describe how web
in the HTML document. page content is to be
displayed

The CSS properties and values for


headers have been moved from being
inline with the HTML and are now
listed under the class selector instead.
Give the class a name and add a full
stop (.) before it so the browser knows
you are defining a class.
Instead of using “ ” to group the
properties, use { }.

The class can now


be used inside the
HTML code when
it is needed.

Generalisation and algorithmic thinking

Use the example shown below to help you create and then use a
class definition for the page header section of your index.html file.

84

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 84 27/04/20 6:18 PM


Unit 8.3 HTML and CSS: Getting your head straight

Practice

➤ Underneath your existing table CSS definition create a class definition called .header
and add style definitions for the background-color, height and width and display
features as shown.

Amend the colour


and height of the
header section if you
wish but keep width
set to 100%

See line 24
➤ Save the file called index.html. in the example
➤ You can call this .header class inside the opening <div> tag by writing shown.
<div class = “header”>.
➤ Preview the web page in the browser.
➤ When you are happy with the display of your web page create your own class
definitions for the following sections of the web page.
o Navigation area (.nav)
o Main content (.maincontent)
o Table (.tablesection).
o Use class=“nav”, class=“maincontent”, and so on to call each class from inside
the opening <div> tag for each section in your index.html page.
o Save index.html.
➤ One of the main advantages about setting up class definitions is the fact that classes
can be reused.
➤ New content can easily be added and the same styles reapplied. This is possible as the
styles have already been defined.
o Open index.html.
o Underneath the last </div> tag in your HTML code (the .tablesection) we can
add some additional text to remind the user if they ever need help. We will use the
.maincontent class to style these elements.

85

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 85 27/04/20 6:18 PM


International Computing for Lower Secondary

o Use <h1> </h1> and <p></p> tags to add the text shown below; an example of
how this might look can be seen on page 86.

Here to help!
Contact any of the above organisations anytime if you need help

o Place a <div> and </div> tag at the start and end of this section of text and use
the .maincontent class to format the paragraph display.

Notice how there is a


small space between the table
o Save index.html and preview your web page in a and the new content. Think
browser window. about adding display:
inline-block to the table
➤ For additional practice creating and applying new styles,
class definition in the
complete the following task. <head> section to
o Create a new class definition called .contactdeveloper. help with this.
This style will be used for a small section (about 100 pixels
in height) which will appear at the bottom of your web page.
o Your new style should contain appropriate definitions for
DID YOU KNOW?
• background-color The <a> tag can be used
• height to create a hyperlink
• width which will automatically
allow the user to send
• display.
emails to a pre-defined
o Create a new <div> at the end of your HTML and apply the address.
style called .contactdeveloper to this div.
o Add the following HTML to your new <div> section at the end
of your HTML document:
Change the email
<p>Last updated (add date here), To contact the web address to your own
designer <a href=“mailto:webdesigner@my _ email. (or your school’s
com”>Click Here</a></p> email address, if you
would prefer to keep
yours private).

86

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 86 27/04/20 6:18 PM


Unit 8.3 HTML and CSS: Getting your head straight

CSS: external stylesheets


Learn

CSS allows web developers to quickly and easily change how web
pages look. Using classes speeds up the editing and coding process
for when amending the presentation of a website. Previously, we
saw how a class can be used more than once in an HTML document.

Homepage

Main Topic Pages

Sub-Topic Pages

Posts

This website has 30 pages. If the website is to look Each page would need
professional each page should have a similar look and feel. all of the classes setting
Discuss with a friend the difficulties of coding and editing up again within the
<header> tags.
classes used over and over again on each of the 30 pages.
<html>
Developers use external stylesheets to store
details of the CSS and classes they wish to
use on multiple pages on their website. <html>
{CSS}
External stylesheets, internal styles and inline
styles can all be applied to an HTML document. <html>
DID YOU KNOW?
An HTML document that contains all three will
Using an external
apply the styles in the following priority order. <html> stylesheet saves you a lot
of work – you can update
Priority order (highest a whole website by
priority at top) Explanation amending that one file.
Inline style CSS which has been incorporated into the body of an HTML
document has the highest priority. It will be applied in place of
CSS included in internal styles or external stylesheets KEYWORD
Internal style Internal stylesheets or CSS which has been included in the external CSS: A
<head> tags of an HTML document have the next highest separate document
priority. They will be applied in place of CSS found in external is written containing
stylesheets. Internal styles must be defined for every page the CSS for a website.
they are used in. Each page in the
website contains a
External stylesheet External stylesheets have the lowest priority. External link to that file inside
stylesheets are saved separately from the main HTML the <head> </head>
document but are called from within the <head> tag. Any tags at the start of an
inline CSS and internal CSS will override the external stylesheet. HTML document

87

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 87 02/05/20 1:04 PM


International Computing for Lower Secondary

Practice
DID YOU KNOW?
Most developers will
Let’s practise creating and using our own external CSS file before make regular copies of
we create our ‘Getting Our Head Straight’ website. First, we need their work, especially if
to make a copy of index.html. they are making a lot of
changes to their code.
➤ Open Notepad++. This is called making a
➤ Open index.html. backup.
➤ Click on ‘File’ and then ‘New’ to create a new blank HTML page.
➤ Highlight the CSS in index.html.
➤ Right click on the highlighted text and select ‘Cut’ from the This file should
drop down menu that appears. now contain CSS
➤ Right click in the new blank HTML file and select ‘Paste’ from style definitions for
the drop down menu. each <div> section
of your practice
➤ Once you have complete the Cut and Paste task the <head>
web page.
tag in the file called index.html should only contain <head>
<style> </style><head>
➤ Save the file containing your copied CSS code as mystyles.css. KEYWORD
➤ Save index.html (with the CSS now removed). backup: the process
You now need to link the index.html document to your of making a copy of a
program or file. This
mystyles.css file.
allows the developer
➤ Edit the <head> </head> in index.html as shown: to restore work if the
original file becomes
damaged
{

When was the last


{
{
{

time you backed up a


file? What was it?

Tells the browser that the linked This is the stylesheet


document is a stylesheet. you have just created.

Specifies there is a Specifies where the linked


relationship between the document is stored.
current file and the linked file.
It allows the web browser
to fetch the stylesheet from
memory before it is used.
This helps speed up the load
time for a web page.

88

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 88 27/04/20 6:18 PM


Unit 8.3 HTML and CSS: Getting your head straight

Go further
Now that you have expanded you knowledge of HTML and are This will help you
able to use CSS you are ready to create the remaining two web later when you are ready
pages for the ‘Getting Your Head Straight’ website. to add an external
stylesheet with
Your web pages should have the following sections (at least). class attributes to your
They will be used to display the following. website.
◆ The header (displaying the charity logo and name).
◆ Navigation (hyperlinks to the other web pages).
o Here’s the syntax for HTML to add hyperlinks to a document:
<a href=“add your web address here”>add your
hyperlink text here</a>
◆ Content (the main content of your web pages).
◆ Images and the location of any images on your web pages. Remember
o Here’s the syntax for HTML to add images to a document: using the div tag
<img src=“filename.filetype” alt=”any rollover on page 85.
text should appear here”>
You are already familiar with the structure of an HTML document
and the various tags required to add content to an HTML document.
Use the storyboards
you created and
the information you
collected to create two
additional HTML pages
for the website.

Make sure that both new pages are saved to the MyWeb folder,
provided by your teacher
◆ Open Notepad++.
◆ Create a new HTML file called selfcare.html.
◆ Add the following HTML tags you need before adding content
to your web page:
<!DOCTYPE html>
<html>
<head> The logo is in the
assets folder provided by
<title> </title>
your teacher when you
</head> completed the HTML
<body> for index.html.
</body>
</html>

89

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 89 27/04/20 6:18 PM


International Computing for Lower Secondary

◆ Decide on the appropriate HTML tags needed to add:


o the charity logo and name
o text you can use as hyperlinks to the other two web pages You should add
comments using
o a title for the main body of text on the web page
<!-- -- >.
o the text you included in your storyboard for the ‘Taking
care of yourself’ web page created during the practice task
on page 69.
o any images you located to help you illustrate the content
of this page.
o add comments to explain your code.
See page 69
◆ Create a link in the <head> section between selfcare.html to help you
and mystyles.css. with this.

◆ Save selfcare.html and preview the file in a browser window


to ensure the styles in mystyles.css have been applied
correctly.
Now repeat this process and create a second web page on
Coping with Stress. You should call this file copingwithstress.
html. Remember to create
◆ Save copingwithstress.html and preview the file in a a link in the <head>
browser window to ensure the styles in mystyles.css have section between
been applied correctly. copingwithstress.html
and mystyles.css
◆ Remember to make sure you have:
o added hyperlinks between each of the pages in the
website
o included a table in your web page about Taking
Care of Yourself
o included a video on your web page about coping If you are unable
with stress. to download an appropriate
video about coping with
For a reminder of how to use any of the tags used stress, add a hyperlink to
previously, visit www.w3schools.com. a website containing an
appropriate video.

90

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 90 27/04/20 6:18 PM


Unit 8.3 HTML and CSS: Getting your head straight

Challenge yourself
Alex is running an online workshop on looking after yourself. He has asked you
to add a small input form to the bottom of the page called selfcare.html.
The form is to be used to collect the name and email address of anyone The signup form
interested in joining the online workshop. for the workshop
➤ Open Notepad++. will be added inside
these tags.
➤ Open selfcare.html.
➤ Open and close a new <div> tag at the very bottom of the HTML
on this page.
➤ Add a suitable heading tag and instructions to the user about the
purpose of the form.
<div> <!-- add signup form -->
<h3>Sign up for our online self-care workshop </h3>
</div>

➤ In HTML the <form></form> tag is used to indicate that a part of the HTML document
contains a form for collecting information from the user.
➤ Edit the HTML to include <form></form> inside the <div> tags.
<div> <!-- add signup form -->
<h3>Sign up for our online self-care workshop </h3>
<form>
</form>
</div>

➤ You can add text boxes and labels to the data form using the <input type = “text”>
element.
➤ Edit the <form> tags to now read:
<form> KEYWORD
This adds an First name: <input type=“text” variable: a named
input field to the name=“firstname”> <br> memory location used
form. The user can add </form> to store data of a
text to the input field. The given type during the
data entered is stored in program execution; a
a variable called variable can change
“firstname”. value as the program
runs
➤ Add similar input text fields for second name and email address.
➤ Save selfcare.html and preview the form in a browser window.
At the moment the form does not do anything. It simply displays the heading and text
boxes created using HTML tags.
If the user is to be able to send their details to Alex, a Submit button is needed on the
form. Another input type element can be added to the form to allow this to happen.

91

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 91 27/04/20 6:18 PM


International Computing for Lower Secondary

➤ Underneath the HTML for the “Email address:” add the <input type = submit>
as shown below:
<input type=”submit”
This adds a button to
value=”Submit”>
the form. The button displays
the word ‘Submit’. When the
user clicks on the button the
web page can carry out some
kind of action.

Before an action can be performed when the user clicks on the Submit button we need
to tell the browser what that action will be.
➤ Edit the opening <form> tag to read:
<form action=”mailto:[email protected]” name=”submit”>

This tells the browser to send the contents of the form to alex@gettingyourheadstraight.
com, when the user clicks on the <input type = “submit”> button.
➤ Save selfcare.html.
➤ Preview the web page in a browser window to ensure the form displays correctly.
When the user clicks on the Submit button the following message appears.

➤ Use what you have learned about CSS and HTML to improve the layout of the form.
You could do this by adding styles to the <div>, or by adding additional spacing
between the form elements.

92

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 92 27/04/20 6:18 PM


Unit 8.3 HTML and CSS: Getting your head straight

Final project and evaluation


Alex had asked for two versions of the website.
The version of the website you have been working on should have a look and feel which
is more suitable for an adult audience. However, Alex would now like you to design a
second version which is better suited to a younger audience.
Use the information provided in the table below to help you think about how an adult
website might differ from a website produced for children.
Websites for children Websites for older users
Larger text (font size) Smaller text (font size)
Brighter colours (children prefer secondary More subdued colours (more professional
colours such as red, blue, green) or subdued colours)
Simple, easy to understand text Complex sentences
Create a new CSS file which contains a new set of style properties which will make the
website more suitable for children.
Carry out the following tasks before creating your new CSS file.
➤ With a friend discuss how you might make the website suitable for children. What
colours, font or style of writing might a younger audience prefer?
➤ Think about the tags you would use to change: background-color, text-color,
text-align , the div height for example. Remember, if you want your div sections to
display without spaces between them, use display: inline-block .
➤ Experiment with font-size and font-style tags
➤ Save your new stylesheet as mystyles2.css into the folder
called MyWeb which contains your index.html file and
the HTML files for the two additional pages in your You can
find out more about
website.
these tags on www.
➤ Link this stylesheet to index.html. w3schools.com/html/html_
<link href=“mystyles2.css” rel=”stylesheet”> styles.asp.
➤ Open index.html to test your stylesheet.
➤ If you are happy with how your web page looks, link the
stylesheet to the remaining two pages.
Alex also wanted a version of the website that would help improve DID YOU KNOW?
accessibility for users with visual impairments. Alt text added to
Website accessibility can be improved in a number of ways, images can also improve
including the following: website accessibility.
Alt tags can be added
➤ Ensure you have included Alt text for all images.
in the form: <img
➤ Use external CSS for styling. src=“filename.
➤ Use simple language on your website. filetype” alt=”any
rollover text
➤ Use contrasting colours on your website for backgrounds and text.
should appear
For users with visual impairments you can improve accessibility by: here”>. Alt text is
1 creating a version of your web page with increased text size used by assistive screen
2 including voice recordings of some of the text so that users who readers to describe the
image.
are unable to read the text can have it played back to him.

93

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 93 29/04/20 8:58 PM


International Computing for Lower Secondary

➤ Make a copy of your MyWeb folder and rename the copy MyAccessibleWeb.
➤ Edit the mystyles.css file to ensure the font displayed on each web page is larger
in size than the previous version of your website.
➤ Create a voice podcast of some of the text on your index.html file.
● Go to www.naturalreaders.com/online
● Copy some of the text from your file called index.html and paste it into the text box
as shown. Experiment with languages and voices until you find one that you like.
➤ Download the mp3 version of the voice to text file and save it in MyAccessibleWeb/assets.

➤ Beside the text recorded in the mp3 file, create a text-based hyperlink which reads ‘Click
here to read this text’.
➤ The website storyboard also showed a Contact Us hyperlink in the navigation bar. Alex
wanted users to be able to email the organisation if they needed more information.
➤ Use www.w3schools.com to find out more about how you can combine the following
tags to convert this text into an email hyperlink.
</a>
<a href=mailto:[email protected]>
Contact Us
The online workshop on taking care of yourself was so successful that Alex has decided
to run another workshop for coping with stress.
➤ Edit copingwithstress.html to include a data input form which can collect the first
name, surname and telephone number from anyone interested in taking part.
➤ The form should be added to a new <div> section at the bottom of the existing
page and users should be able to email Alex at [email protected].
Now that the Getting Your Head Straight website is complete it is important that you
test and evaluate all parts of the website before Alex takes ownership of it.
Your teacher will provide you with a copy of an evaluation table which can be used to
allow you to evaluate your own website.
➤ Open your completed index.html and use the Web evaluation table to help you
evaluate your website.
➤ When you have completed the grid write a short paragraph describing any changes
you made to your website. Say why you made these changes.
➤ Ask a friend to evaluate your website. Your teacher will provide them with a copy of
the same evaluation table. When your friend has finished evaluating your website,
discuss their scores and ask them what additional changes they would make to the
website and why.
➤ If time is available make any appropriate changes to your website and say why you
agreed with the comments your friend made.

94

481992_U3_Int_Com_Low_Sec_SB_067-094.indd 94 27/04/20 6:18 PM


Unit High level programming
8.4 language: Expert story telling
About Python
Python is a programming language created
by Guido van Rossum in 1991. It is widely used
in education to teach programming, and in
business and industry to create programs.
YouTube, Google, Instagram and Spotify all
use Python. The language was created so that
the code could be read and understood easily.
Python’s Integrated Development and
Learning Environment (IDLE) provides features
for creating, editing and running programs.

In this unit you will learn to:


➜ use features of the Python programming language to create a
solution to a problem
➜ use the IDLE interface to code in script mode
➜ create and edit code in Python which
• sequences input, process and output
• uses different data types
• uses arithmetic operators and assignment statements to
perform calculations
• uses built-in Python functions
• is easy to read and understand
➜ use selection in Python
➜ use repetition in Python
➜ use simple validation to ensure user input is correct
➜ test and evaluate a Python program.

KEYWORDS KEYWORDS
IDLE interface: Python’s Integrated Development and Learning Environment selection: selecting
which provides features for creating, editing and running programs statements based on a
data types: the different ways in which data can be stored; for example, number, decision
string, date repetition: repeating
arithmetic operators: +, − , *, / and other symbols which can be used for sections of code in a
arithmetic loop
assignment statements: a statement which assigns a variable a value; for validation: ensuring
example, x=3 that the data entered
built-in functions: functions that can be used in the Python language without by the user is
adding any additional code acceptable

95

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 95 27/04/20 1:59 PM


International Computing for Lower Secondary

SCENARIO
Younger children need to understand the importance of secure
passwords. Your company wishes to promote online safety and as
a programmer you have been asked to create an electronic solo
adventure game for young children aged 8–10 years old. The
adventure 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 will meet a
robot and sweet shop owner on their journey. They need to find the
Chocolate Room in a digital sweet shop.
When they find and enter it there will be two questions. If the
child answers the questions correctly they will be given three of the
letters from a four letter password. They then go on to guess the
password after being given a clue. If they guess the password they
open a digital treasure chest and win the game. KEYWORDS
Your challenge is to examine existing program code and find solo adventure game:
a game in which
out what it does, correct errors in the code and complete the
the player assumes
game. the role of the main
You will need to use the different programs provided by your teacher. character
program code: the
You will add new code, edit code and test any changes made to the Python code created
code to make sure that it works correctly. in the IDLE

DID YOU KNOW?


Do you remember? Do you know that
Python is one of the
Before starting this unit, you should be able to: official programming
✔ create sequences of code to form algorithms languages that is used
at Google?
✔ be able to break down a problem into smaller, more manageable
tasks (decomposition)
✔ understand the terms ‘target audience’ and ‘user requirements’
✔ select an appropriate data type for a data item
✔ make use of selection with IF statements
✔ create a simple flowchart which represents a solution to a
problem
✔ identify when loops can be used to increase the efficiency of an
algorithm
✔ evaluate an application based on the way in which the user
requirements have been met.

96

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 96 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

Using Python

Learn KEYWORDS
interactive mode:
Python is normally installed on a computer with an Integrated the Python shell
Development Environment (IDLE). The IDLE provides lots of allows commands to
functions that are useful when writing Python code. Click on the be entered and run
IDLE (Python) icon on your computer to launch. immediately
Python shell: the
Python can operate in two modes: the first is interactive mode. Python interactive
mode, where
When you launch the Python IDLE, the prompt >>>, on the last commands can be
line, shows that you are in the Python shell. This is the interactive typed directly
mode which allows individual Python commands to be typed print statement: a
directly and carried out. Python statement
used to output text or
values onto the screen
case-sensitive: can
distinguish between
capital and small
letters

In the example above you can see a print statement. The print
statement is a Python command which outputs information
onto the screen. This print statement will output the words Hello
world onto the screen.
The next line (7+6)*2 will output the result of the calculation.
Notice you do not need to use the print command when
performing calculations.
When using Python code you need to ensure that you type Python can use
commands using lower case letters. arithmetic symbols such
as ‘+’ for adding, ‘/’
Python can tell the difference between upper-case (capital) for dividing and ‘*’ for
letters and lower-case (small) letters (it is case-sensitive). multiplying. Remember the
example above: (7+6)*2
For example, if you enter Print(“Hello world”) an error
gives 26.
should occur because ‘Print’ (with a capital ‘P’) is not the same
as ‘print’ (with a small ‘p’). You should always type Python
commands in lower case.
Python also provides help at the command prompt. You can
type help() and find out how to use commands in a Python
program. You can also type help(print) to find out how to
use the print command, such as how you can use it to display
different data types on screen.

97

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 97 27/04/20 1:59 PM


International Computing for Lower Secondary

To close Python type exit(). KEYWORDS


When a command is typed it must be ‘translated’ so that the interpreter: the feature
computer can understand it. The IDLE has an interpreter of Python which
translates the Python
which does this. Each command is changed into a form of
code into language
machine code so that the computer can carry out or execute that the computer can
the command. understand, line by line
Typing commands directly into the Python shell is called machine code: the
language that a
programming in interactive mode. One disadvantage of computer uses to carry
using interactive mode is that the code cannot be saved out instructions
when using Python in this way.

Practice

➤ Open the Python IDLE. (Your teacher will tell you where on the computer you can
access Python.) The Python Shell will open as shown here:

➤ Enter this command at the interactive prompt (>>>), and press ENTER:
print (“Welcome to the Python Shell”)
➤ Now enter a command to print your name onto the screen and press ENTER:
print (“add your name”)
➤ Now try this command:
print (“Hello World)
An error should occur because you have left out a set of quotation marks.
Correct the error and execute the command again.
➤ Try entering this calculation:
(7 + 3 * 2
Look at what has happened this time. Why do you think this is?
Correct the error and execute the command again. The answer
should be 20.
➤ Try entering three or four of your own maths commands. Remember that the ‘*’
(star symbol) is used for multiplying.
➤ Get Python to add 150 and 23 together, and then multiply the
result by 3.

98

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 98 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

Using the Python IDLE in Script mode

Learn

On the previous pages you used the Python Shell to enter single lines of Python code.
These are translated and executed one at a time and they cannot be saved.
Most of the time people write programs with many lines of code which they want to save.
Python can operate in two modes. The first was interactive mode using the Python shell.
To create and save a program, Python’s IDLE is used in the second mode: this is called
Script Mode.
You use a text editor (a bit like Notepad) which allows you to enter and save lines of code.
Create a program
Follow these steps to create a new
program.
➤ From the Python Shell select
‘File’.
➤ Then select ‘New File’.
➤ A new window will open and you
can enter lines of code into this
text editor.
Type the command shown on the
right into the new file.
Save a program
Follow these steps to save the
program.
➤ From the text editor menu select
‘File’.
➤ Then select ‘Save as’.
➤ Call the program ‘HelloWorld’ and
save it. (Note: all Python programs
will have .py at the end to show
that they are Python files.)
Run a program
Once you have completed the code
you can run the program.
➤ From the text editor menu select
‘Run’.
➤ Then select ‘Run module’ (or
Press F5). This will cause the
Python interpreter to execute the
program.

99

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 99 27/04/20 1:59 PM


International Computing for Lower Secondary

➤ The output from the program will appear in the window of the
Shell. In this case you should see the words ‘Hello world’ in the
Shell window.

Correct errors
Here’s how to correct errors in Script mode.
Look at the code in the screenshot below. There is an error
(remember that Python can tell the difference between capital
and small letters).
Can you see the error?
If there are errors in the code, they will be
highlighted in red after you Run or
execute the program:
The only way to correct errors in Script mode is to open the program and correct the
mistake in the code.

Open a program
Follow these steps to open an existing program.
➤ From the Python Shell select ‘File’.
➤ Then select ‘Open’.
➤ Select the name of the file you wish to open.
➤ Edit or correct the code.
➤ Save the program.

Add comments
Here’s how to add comments to a Python program.
Adding comments to code
allows you to explain what the
code does or to provide extra
information about the code.
In Python you can do this by
starting the comment with a
hash (#) symbol. Any text on
a line after a # symbol will be
ignored by the interpreter.

KEYWORDS
script mode: Python’s text editor which allows programmers to enter a list of commands and they are
executed together
execute: another word for running a program
comments: text entered by the programmer to improve the readability of the code. They start with the #
symbol in Python

100

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 100 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

Practice

➤ Open the file called ad1.py provided by your teacher.


➤ This file shows some of the introduction screen for the game.
As the programmer you must add two comments to the code
(remember to use the # to start a comment):
1 Add your name as a comment.
2 Add today’s date.
➤ Run the program and look at the layout of the story on the
screen. Discuss with a friend how you could improve the
layout of the story on the screen. Ask these questions:
o Do you need to split any of the lines because they are
too long? You can split the code by separating one print
statement into two statements. For example, this is quite a
long print statement:
print(“You will meet two people - one is
the sweet shop owner who wants to steal the
password so he can keep the sweets.”)
o Why not split it into two statements like this?
print(“You will meet two people - one is the
sweet shop owner who wants to”)
print(“steal the password so he can keep the
sweets.”)
o Do you need to add extra print statements to improve the
layout and readability of the story? For example, you can
add a blank line between statements by adding a blank
print() statement, like this :
print(“You will meet two people - one is the
sweet shop owner who wants to”)
print() If there are errors
in your program, go to the
print(“steal the password so he can keep
line identified in the error
the sweets.”) message and check the spelling
➤ Add in some code for blank lines to space the text of the word print.
out on the screen. Do this by inserting print() on a
line on its own. Check that you have two
➤ Edit the code to improve the layout of the story brackets around the text and check
on the screen based on your discussions. that there are two sets of quotation
marks around the text.
➤ Run the program and make sure the text in the story is
laid out as you expect.
➤ Ask a friend to look at it and tell you if it is easy to read and
understand.

101

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 101 29/04/20 9:05 PM


International Computing for Lower Secondary

Capturing user input


Learn
KEYWORDS
You have already seen how to output information onto the variable: a named
screen using the print statement. A computer program should memory location used
to store data of a
also be able to accept input data from a user (for example the given type during the
user should be able to answer questions or enter values on the program execution; a
screen). variable can change
value as the program
Variables are used to store data in a program.
runs
A variable is a named location in the computer’s memory which integer: whole number
stores data of a particular type. Data is entered by the user string data type: data
whilst the program is running. which is made up of
letters, numbers or
Variables can hold data of different types. In order to store data you any characters on the
must decide on a name and a data type for the variable first. For keyboard
example, to store the player’s age you will need to name a variable input: a function
which can hold a whole number (also known as an integer): which Python uses to
capture string data
Variable Name Data Type from users
playerage integer

To store the player’s name you will need a variable which can
hold letters – this is called a string.
Variable Name Data Type
playername string

The variable names have been chosen as playerage and


playername but they could have been called anything we wanted.
Variables can hold different data types. The table shows some
examples of each data type.

Data Type Example


String Any textual characters, such as ‘Hello World’ or ‘WWW1234’
Integer Any whole number, such as 1 or 345 or 1000
Real Any number with a decimal point, such as 1.2 or 56.8 Notice that the
Boolean True or False; used when evaluating conditions in an IF string data type can include
statement numbers. You may wonder why
there is a separate data type for
To capture data from the user you use the input function. integers and real numbers. If numbers
The input function captures user input as a string data type. are stored as a string
This contains numbers, letters and symbols. For example data type then Python does not
know they are numbers and
‘Robot’, ‘Password123’ and ‘**WWW777’ are all examples of
cannot use them in
string data type. calculations.
Input is a built-in function in Python – it is part of the Python
language.

102

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 102 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

The input statement prints a question onto the screen and


captures the user’s answer to the question in a variable called
playername.

playername is then used in the next line of code and printed


onto the screen as part of a welcome message. Can you guess
what will be printed onto the screen?

Practice

You are going to practise using string data types.


➤ Look at the code shown below. Running the code has produced an error in red text. Try
to identify the error in the code.

➤ The error has now been corrected. Look at the code below:
➤ Write down what you think the outputs will be on a piece of paper. You should include
everything that is being printed out onto the screen.
➤ Exchange your drawing with a friend.
➤ Open the file called stringpr2.py provided by your teacher, run it and check your
drawing to see if you are right.
A robot called Botty in the Digital Sweet Shop game is going to create some
directions so that you can get to the sweet shop. He has emailed the following
directions to you:

Greetings my friend. If you want to go to the Digital Sweet Shop you must walk across
the long street and turn left at the traffic lights. There is a large shopping centre on the
corner. Turn left here and you will see the Digital Sweet Shop beside the flower shop. The
flowershop owner has a dog called Biscuit who barks all the time. Be careful he can bite!

103

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 103 27/04/20 1:59 PM


International Computing for Lower Secondary

➤ Open the file robot.py, provided by your teacher. It contains the program which Botty
is using to send your email.
➤ Unfortunately his motherboard has become damaged. Run the program and look at
the output. You will see that the strings are all mixed up.
➤ Edit the code so that the message Botty sends matches the one above.

Learn

The input function can only capture data integer data types in one single print
as a string data type, so if you need a statement. So, if you want to print the
number from a user that you want to use player’s age together with some words
in a calculation, you will need to convert you must convert their age back to a
the string data type to a number data string value.
type.
The str() function will change an integer
Your adventure game will ask the age value to a string value.
of the players to ensure they are allowed
For example let’s say the player enters
to play the game. We can ask them
an age of 8, and the program has
to input their age using a statement
converted their input to an integer data
such as:
type called playerage . To display some
input(“What age are you? “) words along with their age you would
write:
We want to store their answer as a whole
number (or integer) because we want to print (“You are aged “ + str
perform a calculation with it. However, (playerage))
as we know, this input statement only
Integer String
stores string values. Python uses the int()
function to change the string value from playerage str(playerage)
the input statement into an integer (or 8 “8”
whole number).
If we use a variable called playerage to
hold the player’s age as a whole number,
then we can add the following statement to The int() function is added to the input
convert the input string to an integer statement and this converts the data to
(or whole number): an integer value and stores it in a variable
called playerage.
playerage = int(input(“What age are
you? “)) playerage is then used in the next line of
code and printed onto the screen as part
Integer String
a message. The print statement can only
playerage input(“What age are you? “) print data of type string; therefore, the
A single print statement can only playerage must be converted to a string
display data of the same type. You for printing. The str() function is applied to
cannot combine string data types with the playerage to convert it to a string.

104

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 104 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

Practice

➤ Botty the robot has to be able to


calculate the average score for the
pupils who play the game. He has
managed to program himself to do
it for two players but needs help to
do it for all five.
➤ Open the file called robot2.py,
provided by your teacher.
➤ It contains Botty’s code but he
needs it to work for five values.
o Add three more input statements so that you can enter five scores.
o Change the total score calculation so that it calculates the total for five scores.
o Change the average formula so that the average for five values is calculated.
➤ Change the print statement so that the program outputs the following message
before printing the average: “The average of the five scores is”.

Learn

The value of a variable can also be set by When you use a variable it is sensible to
using an assignment statement. This gives give it a starting value at the start of the
the variable a value. program. This is known as initialising the
In your adventure game the player will start variable.
with three lives and two bars of chocolate. Below are two initialising assignment
Two variables are needed to hold this data: statements for the adventure game:
one variable for the lives and one variable playerlives is assigned a value of 3 and
for the chocolate. chocolate is assigned a value of 2.
In the game these variables are called
playerlives and chocolate.
A player can lose a life or eat a bar of
chocolate during the game to get help with
certain challenges. This means the value An assignment statement includes an
of these variables can change during the equals symbol and takes the form:
game. Assignment statements use the
equals sign to do this. name of variable=value
Notice that, when
for example:
For example, if a player loses a life, then we assigning a string to
need to remove ‘1’ from the playerlives playerlives=3 a variable, you need
variable: total=score1+score2 to use quotation
playerlives=playerlives-1 playername=”George” marks.

Or, if a player eats a bar of chocolate, then


we need to remove ‘1’ from the chocolate KEYWORD
variable: initialise: setting a variable to a starting value.
For example, x=0
chocolate=chocolate-1

105

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 105 27/04/20 1:59 PM


International Computing for Lower Secondary

Practice

➤ You have already used assignment


statements in Botty’s average
calculation program in the last section.
➤ Open the file called robot3.py,
provided by your teacher. Add
assignment statements to carry out
the tasks shown in the screenshot on
the right. The first one has been done
for you.
➤ Add a print statement to carry out the
task in number 6.

Practice

Now try these tasks using some code from the adventure game:
➤ Look at the code below.

➤ There are some errors in the code. Look at the hints in the code and write down how
you would fix these two errors.
➤ With a partner, write down what the code will do when the errors are fixed. Explain
the code using information about the:
o print statements
o assignment statements
o input statements.

106

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 106 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

➤ Now open the file ad2.py, provided by


your teacher.
➤ Run the program. You will find that
there are two errors and some repetition in the code. Use your previous analysis above
to help you:
o fix the error on line 9 which is stopping the program from running
o fix the error on line 12 which is stopping the program from running

o run the program and ensure that the errors have been fixed
o save the program. Look at page 102 to
➤ Edit the code so that the user can enter a name for the robot remind yourself how
they will meet into a variable called robotname. Save the to get an input from
program. the user, then save
the program.
➤ Edit the code so that the program outputs a suitable
message to the user about their choice of name for the
robot. Save the program.
➤ Look at the output created by the line below. There is a small problem here. Hint: when
you run the program check to see how the output from this line looks on the screen.

➤ Edit the program so that the output on the screen is


correctly presented. Save the program. You should think
about how to
➤ Edit the code so that the user is asked to enter the number of
convert an input
times that they have already played this game. This question from a string to
should appear after they are asked to enter their age. a number – see
➤ Store the data in a variable called gamesplayed . page 104.
➤ The rules of the game have changed and
players now only have one bar of chocolate.
Edit the code so that this is the case. Remember that the
➤ Edit the code to so that the user details are print function can only output
data of the same type. Therefore,
output onto the screen together after both
gamesplayed needs to be
questions have been asked, instead of after
converted to a string using the
each value has been input. str() function. Look at the previous code
and the Learn box on page 104
to remind you how to input
a numeric value.

➤ Save the program.


➤ Run the program.
➤ Fix any errors that have arisen.
➤ Ask a friend to review your program and discuss other changes you could make to
improve how the program appears to the user.

107

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 107 27/04/20 1:59 PM


International Computing for Lower Secondary

Adventure choices
Learn

Selection
Sometimes decisions have to be made in a program. This is usually because the
program has reached a point where there is more than one option or choice. For
instance, in the adventure game players must enter their name and age and then
(if over 8 years old) they will enter a name for the sweet shop owner. Then there
are a number of possible pathways for the program to follow depending on how
the player answers certain questions.
Selection occurs when a question is asked. It is important in programming because the
programmer can offer the user choices about the way in which they move through the
program. Selection is achieved by using IF statements. You should already have some
experience of IF statements.

The structure of an IF statement


Here are two simple IF statements:
if playerage>10: Condition 1 is that playerage is greater than 10.
print(“You are too old to play this game”)
if playerage<8: Condition 2 is that playerage is less than 8.
print(“You are too young to play this game”)
This statement uses two conditions and two IF statements.

Remember logical operators:

Equal to == Remember: A condition


contains a logical operator.
Not equal to !> The logical operator combines
the parts of a condition
Less than < together. For example
playerage>10 is a
Greater than > condition. The condition
can evaluate to
Less than or equal to <=
true or false.
Greater than or equal to >=

IF statements can be extended to IF–ELSE statements which allow for more than one
outcome.
if condition statements are be carried out when the condition is true.
else statements are carried out when the condition is false.
When a condition in an IF statement evaluates to true, the indented statements following
IF are executed (but the statements following ELSE are not executed).
When a condition in an IF statement evaluates to false, the indented statements following
ELSE are executed (but the statements following IF are not executed).

108

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 108 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

For example, this IF–ELSE statement allows for two different outcomes:
if (playerage>=8:
print(“You can play this game”)
else:
Yes Print ‘You can
print(“You cannot play this game”) Playerage >= 8
play this game’

Here is a flowchart representing the solution. You


can see the two possible paths:
1 one for ‘Yes’, when the condition is true and the No
statements following IF are carried out
2 one for ‘No’, when the condition is false and the
statements following ELSE are carried out. Print ‘You cannot
play this game’
The exact way of writing IF–ELSE statements in
Python is as follows:

Note the indentation used in


if condition: the lines following if and else. This is
#statements to be achieved by typing four spaces or pressing the tab
carried out when the key. Python uses indentation so that it knows which
condition is true statements belong with if and which belong with
else: else. Review the flowchart above: in Python code,
#statements to be the print statements would need to be indented.
carried out when the
condition is false You must include the colons in an
IF–ELSE statement.

As you develop the adventure game you will have to use IF–ELSE statements. For example,
as the game is for children aged between eight and ten, no child under the age of eight
should be allowed to play. In this section of code, the IF–ELSE statement has been used to
select which code will be carried out based on the age entered by the player. For example,
what happens if a player is under eight, and what happens if they are eight or over?
The following code and section of flowchart represents a solution to the problem:

KEYWORDS
No condition: an expression
Is playerage < 8? [Execute rest of the code]
which evaluates to true
or false; for example,
X<10?
suite: a section of code
which has been indented
Yes
at the same level
indent: move the Python
code in by four spaces
Print ‘{PLAYERNAME} dedent: move the
you are too young to play
Python code out by four
this game! Sorry!!”
spaces

109

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 109 02/05/20 1:06 PM


International Computing for Lower Secondary

DID YOU KNOW?


Indentation (adding
spaces before program
statements) is used in
Python. This refers to
the spaces that are used
at the beginning of a
statement.

The condition for checking the player’s age is:

if playerage<8

This means that, if the player enters an age less than eight, they
will not be allowed to play the game and the message ‘You are too
young to play this game! Sorry!!’ appears on the screen.
You can use the indent
If the player enters an age of eight or more, the statements function on Python’s
following the ELSE statement are executed. menu to highlight
code and indent it all
From the code above, you can see that the next stage is to give together.
the sweet shop owner a name. If you want to remove
the indent, you can
Note that the indentation (spaces before statements) is very highlight the code and
important because this is how Python decides to group statements use the dedent feature.
together. The statements with the same indentation belong to a This will move all
group and are called a suite. Python will indent the statements highlighted code out by
four spaces.
automatically after you type the ‘:’ symbol.
If indentation is not correct you will get an error because Python
needs to know which statements to group together.

Practice

➤ Open the file indentfile.py


provided by your teacher.
➤ The file has errors because
the indentation of the print
statements is incorrect.
➤ Select the print statements
as shown.
➤ Use the dedent option to
bring the print statements
back to the correct position.
➤ Save the program.
➤ Run the program.

110

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 110 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

Learn
Remember:
Combining conditions
AND and OR are called Boolean operators.
Decisions sometimes need to be made
based on two or more conditions. AND needs all of the conditions to be true to
Example 1: if you help Botty with execute the statement that follows
directions to the Digital Sweet Shop OR
OR needs only one of the conditions to be
help with his calculations, then you can
true to execute the statement that follows.
have some sweets.
Example 2: if you help Botty with directions to the Digital Sweet Shop AND help with his
calculations, then you can have some sweets.
What is the difference between the way in which conditions are combined in Examples 1
and 2? Does using AND and OR make any difference?
The answer is yes. In Example 1, you only need to do one of the two tasks. In Example 2,
you must do both.
IF statements can be combined using logical operators, such as AND and OR.
Look at the following IF statement. It is more efficient than the previous examples as two
conditions have been combined into one:
if (playerage>=8 and playerage<=10): Condition 3 is made up of two conditions; this
print(“You can play this game”) statement is to be carried out only when both
condition 1 (playerage>=8) AND condition 2
(playerage<=10) are true.
When a condition in an IF statement evaluates to true,
the statements following IF are executed.

Remember: Using the AND operator will give an overall outcome of true if both condition
1 and condition 2 are true; otherwise it gives an overall outcome of false. Using the OR
operator will give an outcome of true if either condition 1 or condition 2 is true; otherwise
it gives an overall outcome of false.
Here is another version of an IF statement which uses two conditions combined with the
OR operator.

What are the rules for evaluating conditions combined using an OR operator?
Condition 1: playerage<8
Condition 2: playerage>10
Boolean operator: OR
This table shows what will be printed by the program for a few different ages.

111

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 111 27/04/20 1:59 PM


International Computing for Lower Secondary

Player age entered Print statement executed


10
7 You are not the correct age to play this game! Sorry!!
9
20 You are not the correct age to play this game! Sorry!!
6 You are not the correct age to play this game! Sorry!!
12 You are not the correct age to play this game! Sorry!!:

Multiple conditions can also be used within IF–ELSE statements.


For example, this IF–ELSE statement allows for two different outcomes:
if (playerage>=8 and playerage<=10): if condition 3:
print(“You can play this game”)  statements to be carried out when condition 3 is true (and
else: condition 3 is only true when conditions 1 and 2 are true).
print(“You cannot play this game”) else:
 statements to be carried out when condition 3 is false, where
condition 3 = playerage>=8 AND playerage<=10
When a condition in an IF statement evaluates to true,
the statements following IF are executed. Otherwise, the
statements following ELSE are executed.

Practice

➤ Look at these IF statements relating to the playerage:


if playerage>10 or playerage <6: Player age entered Print statement executed
print(“You can play the game”)
10 You cannot play the game
else:
7
print(“You cannot play the game”)
9
➤ Using the IF statements above, copy and 20
complete the table by writing which print
6
statement will be executed for each of the
player ages entered. The first one has been 12
completed for you.
➤ Discuss with a friend, how this IF statement will change the age rules for playing the
game.
➤ Create a new IF statement which will ensure that players aged 7 to 11 can play the
game. Use the following partially completed IF statement to help you.
if playerage >=7 AND ____________________________:
print ____________________________
else:
print ____________________________

112

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 112 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

Algorithmic thinking

Draw a flow diagram for a program that does the following:


✪ A player enters their age.
✪ If the player is aged between 13 and 19, the program prints the words: “You are a teenager!”
✪ If the player is any other age the program prints the words: “You are not a teenager.”

Learn

The player has now entered data for:


playername, playerage, gamesplayed, ownername and robotname.
Now they must decide whether or not to enter the Digital Sweet Shop.
The program should ask the user if they want to enter the shop. The user will have to
answer this question. If they enter ‘Y’ that means ‘Yes’. If they enter ‘N’ that means ‘No’.
We must store the user’s response in a variable. Let’s call the variable entershop.
An IF statement is used to check the value of entershop.
Look at the code below and discuss what happens if the player enters ‘Y’ (for yes) or ‘N’
(for no).

Note the condition in this case:


if entershop== “Y”

Why do you think we use ‘==’ instead of ‘=’? Look at the table below.

Assignment statement entershop=“Y” Sets the value of the variable entershop equal to ‘Y’

Comparison entershop==“Y” Checks the value of entershop to see if it is equal to ‘Y’

When checking the value of a variable in a condition, you should use the == symbol.
When you want to assign a value to a variable, you should use the = symbol.

113

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 113 27/04/20 1:59 PM


International Computing for Lower Secondary

Practice

➤ Copy and complete the following table by inserting either = or ==.

Task = or ==
set the player age equal to 9 playerage 9
check to see if the player age equals 11 playerage 11
set the games played equal to 0 gamesplayed 0
check to see if the gamesplayed equals 3 gamesplayed 3

➤ Look at the code shown below. A syntax error has occurred. Python has rules for
spelling and grammar. These are called syntax rules.
A syntax error occurs when a statement is written incorrectly. For example, a misspelt
word or variable name or missing brackets. A program cannot run if there are syntax
errors, they must be corrected first.
Can you tell what the problem is here?

➤ Now try these tasks using some code from the adventure game:
o Open the copy of ad5a.py, provided by your teacher.
o Run the program and see what the output is from the program when you enter
different values for the player’s age.
o Edit the code so that the message for a player under eight reads:

Sorry [NAME OF PLAYER], you are only [AGE] years of age and are too young to
play the game.

So, for instance, if the player was called Yang and was aged seven, the message
would read:

Sorry Yang, you are only 7 years of age and are too young to play the game.

You can do this by editing the print statement following


the IF statement. You will need to change the order of the Look at the print
things in the print statement. For example, the statements used to
playername will have to come after the word ‘Sorry’. output the ownername
and the robotname on
to the screen.

114

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 114 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

Decomposition
✪ Use the file flowchartIF.docx, provided by your teacher. Complete the flowchart which
represents a solution to the following problem.
In the adventure, when the player goes upstairs in the shop, they are presented with a
choice. The player can go left or right at the top of the stairs. Different things will happen
based on their choice. Unfortunately, there is a hole in the floor to the right and so the
player will lose a life if they choose right. So, the game will take one life away and place the
player at the top of the stairs at a door. If the player goes to the left, they go straight to the
door at the top of the stairs without losing a life.
You need to add these steps to the flowchart.
o The program outputs this first message onscreen: ‘You have reached the top of the
stairs and you can go right or left’.
o The program asks the user to enter ‘R’ for right and ‘L’ for left, and stores the user’s
response in a variable called direction.
o If the player enters ‘R’ the program outputs the message ‘You have fallen through
the hole in the floor and lost a life – you must start again’.
o If the player enters any letter other than ‘R’ the program outputs the message ‘You
are standing at the door of the Chocolate Room’. This is not what we want - we only
want this message to appear when they enter ‘L’. We will however resolve this issue
a little later on.
✪ Ask a friend to review your flowchart to ensure that the solution is correct.
✪ Modify the flowchart if necessary.

Algorithmic thinking

✪ Turn the flowchart into Python code on a piece of paper using a pencil. Use the code in the
file ad5a.py to help you create the new section of code.
✪ Write a print statement to output the first message to the player:
‘You have reached the top of the stairs and you can go right or left’. Hint:
✪ Write an input statement with a message to capture the user’s direction=
response in a variable called direction. input
( )
✪ Write an IF–ELSE statement and conditions to check the value
of the variable direction and to output the correct message for
R and L.
✪ Write a few comments to explain the code. Hint: start
Start each comment with the # symbol. with if
✪ Review the code with a friend and look out for any syntax errors direction==
such as:
o missing quotation marks
o too many brackets or missing brackets
o misspelling of variable names or keywords like print and input
o incorrect use of capital letters.
✪ Correct any visible errors.

115

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 115 27/04/20 1:59 PM


International Computing for Lower Secondary

Practice

➤ Add the code you have written to the program ad5a.py, following the line:
print(“Let’s go.....up the stairs”)
Note that the program will show you where to put your newly written code. Look for
the line:
“#continue your code here at this level of indent”
around line 64.
➤ Save and Run the program.
➤ Correct any errors that have occurred. You have seen syntax errors but programs
can also contain logic errors. These occur when there is an error in the logic of the
program. For example, parts of the program may be missing, in the wrong order or
could be using the wrong data. The program will run but may not
produce the correct output. Hint: look
at the IF
➤ The section of code below contains a logic error. Look at the
statement.
code and discuss what is wrong with it, with a friend.

➤ Testing is an important part of creating a program. You need to know that the
program works correctly. A test plan will help identify errors that could occur. A test
plan can be created using a table with columns as follows.
Does Expected
Outcome match Type of error
Variable to Reason for Value to Expected the Actual (Syntax or
Test test test be used Outcome Actual Outcome Outcome? (Y/N) Logic)
1 playerage player too 7 too young too young Y None
young message message
2 playerage player 9 player can player can Y None
correct age proceed proceed and
and play play game
game
3

➤ Create a test plan for your solution using different values for the variables playerage,
entershop and direction . You can do this by creating a table with the headings
shown above.
➤ Test your program using the test plan you have created and correct any errors in the code.

KEYWORDS
logic error: when the program does not do what the programmer wanted it to
test plan: a document containing information about how the program will be
tested and the data used to test it

116

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 116 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

Adventures with lots of choices: going upstairs


in the house
Learn
KEYWORD
What if the player had more than two directions to take at the top ELIF: a statement
of the stairs? Let’s add another direction – ‘S’ for straight ahead. which is part of an
IF statement but
Python uses the ELIF statement to allow you to check multiple provides an alternative
conditions for TRUE. This means that if a condition evaluates to pathway. There can
true, the block of code following that particular ELIF statement be multiple ELIF
will be executed. statements in one IF
statement
Using IF–ELSE statement with three directions:
if direction==”R”:
print(“You have fallen through the hole in the floor and lost a life.”)
if direction==”L”:
print(“You are standing at the door of the Chocolate Room.”)
if direction==”S”:
print(“You reach a dead end. You turn around and this time turn left
at the stairs.”)
else:
print(“You were meant to enter R, L or S! Never mind - you decide to go left

and reach the Chocolate Room.”)
All of the IF statements are executed one after the other even if the correct one is found.

Using ELIF statement with three directions:


if direction==”R”:
print(“You have fallen through the hole in the floor and lost a life.”)
elif direction==”L”:
print(“You are standing at the door of the Chocolate Room.”)
elif direction==”S”:
print(“You reach a dead end. You turn around and this time turn left at
the stairs”)
print(“You are now standing at the door of the Chocolate Room.”)
else:
print(“You were meant to enter R, L or S! Never mind - you decide to go
left and reach the Chocolate Room.”)
● We can add as many choices as necessary using ELIF.
● ELIF is more efficient because, once the correct IF statement is found, the program will stop checking.
● We can add a statement which is executed if none of the IF or ELIF statements are true.

We would like the player to enter ‘R’, ‘L’ or ‘S’. However, they could enter any other letter
too. If they did we would like to display the message: ‘You were meant to Enter R, L or S!
Never mind – you decide to go left and reach the Chocolate Room.’ We can write either
of the following to do this:

117

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 117 27/04/20 1:59 PM


International Computing for Lower Secondary

ELIF makes writing code easier when we have to think about a lot of options.
➤ Like the ELSE statement, the ELIF statement is optional. That is, you do not need to
have one in an IF statement.
➤ However, whereas the ELSE statement can only be used once in an IF statement, the
ELIF statement can be used as many times as needed.
The structure of a statement containing ELIF is shown below.
if condition1:
statements to be carried out when condition1 is true
elif condition2:
statements to be carried out when condition2 is true
elif condition3:
statements to be carried out when condition3 is true

The else statements are to be carried out when none of the above conditions is true.
The flow chart below shows how the different Python statements in the example above
are selected when using ELIF.

Yes If No
direction = ‘R’

Yes If No
Print “You have fallen through a direction = ‘L’
hole and lost a life”

Print “You are standing at Yes If No


the door of the Chocolate Room” direction = ‘S’

Print “You were meant


Print “You reach a dead end.
to enter R, L or S! Never
You turn around and this time
mind – you decide to go left
turn left at the stairs”
and reach the Chocolate Room”

Rest of code

From the flowchart above, you can see that only one set of statements will be executed.
So, if a player chooses to go to the left, only the instruction
print(“You are standing at the door of the Chocolate Room.”)
will be executed. After this, the program will exit out of the entire IF statement and
continue with the rest of the code.

118

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 118 02/05/20 1:07 PM


Unit 8.4 High level programming language: Expert story telling

Decomposition

✪ Look at the code on the right. Discuss with a


friend what the output would be if you enter
the following values: x=4, y=7; x=8, y=8; x=11,
y=21.
✪ Look at the code below on the right. Which
message will be output if you enter the
following values:
x=5, y=4, z=11
x=7, y=7, z=99
x=12, y=21, z=0
✪ Create a set of values for x, y and z so that
the message ‘Hello world’ is output.

Practice

Open your version of ad5b1.py, provided by your teacher.


You are going to add the code for:
➤ when the user selects ‘L’ to go left at the top of the stairs
➤ when the user selects ‘S’ to go straight on at the top of the stairs.
You can use two separate ELIF statements for this. Add the ELIF statements in the
position shown below.
If they select left, include the following print statement:
print(“You are standing at the door of the Chocolate Room.”)
If they select straight on, include the following print statements:
print(“You reach a dead end. You turn around and this time turn left at
the stairs.”)
print(“You are now standing at the door of the Chocolate Room.”)

➤ Save and run the program.


➤ Look at the code below ELIF. What happens if a user tries to enter a value which is not
‘R’, ‘L’ or ‘S’?
➤ Using the flowchart on the previous page, add a final ELSE statement to print a
message if the user does not enter ‘R’, ‘L’ or ‘S’.

119

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 119 27/04/20 1:59 PM


International Computing for Lower Secondary

Learn

Taking away a life


A variable is needed to keep track of the player’s lives.
A variable called playerlives will be used. Each player starts with three lives, so
playerlives will be set to 3 using an assignment statement:
playerlives=3
To increase the value stored in the variable by one, we use an assignment statement.
playerlives=playerlives+1
In this example:
➤ playerlives was assigned the value of 3
➤ add 1 to the current value of playerlives
➤ store the new increased value back in the variable playerlives
➤ print the new value of playerlives, which is now equal to 4.

Practice Computers have


to do things in simple steps.
➤ Open the file called When performing this subtraction,
we need to tell the computer
ad5c.py provided by your teacher. You are going
to take the current value of
to write code to reduce the player’s lives if they
playerlives, subtract one from
choose to go right. it and then store the result of the
The playerlives variable has been set to 3 at calculation in the variable called
the start. That means every player has three playerlives, like this:
lives to start with.
playerlives=playerlives-1

➤ Now add a statement which will subtract a life from the player
if they select ‘R’ for right in the program. Add the line of code
where you see the comment.

➤ Add a print statement after your new line of code to tell the
player that they have lost a life.
➤ Save the program.
➤ Run the program.
➤ Does it do what you expect it to?

120

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 120 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

Answer the robot’s question


Learn

In the next stage of the game, the player The player must guess by entering the
meets the robot at the door of the numbers 1, 2 or 3.
Chocolate Room. The robot asks the player ➤ If the player gets the question right then
a question to make sure that they know the robot will give the player 2 bars of
about secure passwords. chocolate.
The robot will ask the question then ➤ If the player gets the question wrong the
give the player a choice of 3 answers. player will lose a life.

Decomposition and algorithmic thinking

The process of answering the question in the game can be broken into steps using
decomposition. Then you can use algorithmic thinking to create a set of steps or a flow
chart to solve the problem.
✪ Consider the steps involved in this process:
The robot asks the question
The player enters their answer
The program checks the player’s answer against the correct answer
If the player’s answer is correct
the player gets 2 bars of chocolate
if the player’s answer is wrong
the player loses a life
✪ Open the file called ad5b3Start.py, provided by your teacher.
✪ Go to the section # Answer the robot’s question .

Remember to
indent the code
as shown in the
comments.

✪ In pairs look at the comments in this section and write down the lines of code required to
replace the comments.
✪ Replace the comments in red in the code with the correct Python code.
✪ Save the program.
✪ Run the program and check to see if it works correctly.
✪ Check over the code for errors.

121

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 121 27/04/20 1:59 PM


International Computing for Lower Secondary

Validating user input


Learn
KEYWORDS
while loop: a loop
As the programmer of the game, you want to ensure that user input which will continue to
is acceptable and correct. Therefore, you should use validation. run while a condition
is true
You are going to check the user’s response to the question at the
counter variable: a
start of the game: variable which is used
‘Do you enter the shop? Enter Y for yes and N for no.’ to count the number
of times a loop has
The program needs to ensure that only Y or N is accepted. been executed; it is
You can use a loop to make sure that the user enters a value that usually increased by 1
each time the loop is
the program will accept.
executed
While loop
The while loop repeats a series of programming commands
while a condition is true. It is structured as follows:
while condition
statement(s)
The following piece of code will keep looping until the user types
‘Y’ or ‘N’. As soon as they type ‘Y’ or ‘N’, the program would
move on to the next piece of code in the program (not shown in
the screenshot).

A while loop can also be used to count using a counter variable.


This is useful if a programmer wants to keep track of the number
of times something happens in the game.
For example, to print out all of the numbers from 1 to 9, the
following loop would be used:

The variable number is used to count through the loop.

122

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 122 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

Practice
➤ Look at each of the loops on the right.
➤ With a partner discuss what will happen on
screen when each loop is executed.
➤ Loop 2 is not correct – can you suggest what
needs to change to make it work?
➤ Open the file whileloops.py and run the
program.
➤ Were your answers to the above questions
correct?
➤ Did you get the answer to
loop 2 correct? If not you will
find the correct code in loop 5 Hint: The two
in the program whileloops.py. conditions used
are not correct.

Go further
Look back at
Consider how you could validate the user input for answering
page 122 to remind
the robot’s question about passwords on page 121. The input yourself about
can only be between 1 and 3. while loops.
You will need to break the problem down into a number of
steps. To validate the input, you are going to create a while loop
for the game.
◆ Open the file called ad61.py, provided by your teacher.
◆ Examine the code in the section #Answer the robot’s
Use the input
question . statement to
◆ Write a statement which will ask the user to enter a value do this.
between 1 and 3.
◆ Write a condition on paper, which will check to see if
playeranswer is not between 1 and 3. You can do this by
◆ Replace the two comments highlighted in the screenshot creating two conditions
below with your two new lines of code. Do not forget to put a and using the OR logical
‘:’ at the end of the conditions otherwise an error will occur. operator. Condition 1:
playeranswer <1 OR
Condition 2:
playeranswer >3.

◆ Save the code.


◆ Run the code.
◆ Ensure you correct any errors.

123

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 123 27/04/20 1:59 PM


International Computing for Lower Secondary

The Chocolate Room and ending the game


Challenge yourself
Once the player has answered the robot’s question they enter the Chocolate Room, where
they find the sweet shop owner. She will ask the player a question as follows:
‘Which of the following could be used as a good password 1. Your pet’s name. 2. Password123
3. A random set of numbers and letters.’
(The correct answer is 3)
If the player enters 3 they can pick one of two chocolate bars by entering a number 1 or 2.
➤ If the player picks chocolate bar 1 there is no information in it and they lose a life.
➤ If the player picks chocolate bar 2 the letter “T” is inside the wrapper.

If the player gives the wrong answer (1 or 2) to the owner’s question they lose all their
chocolate and lose a life.
Some of the code for the Chocolate Room has been completed for you.
With a friend look at the code.
Your challenge is to add the lines of code that are missing for the Chocolate Room.

➤ You can do this by opening the


file ad62.py, provided by your
teacher and add the required
lines of code.
Ending the game
➤ Once the player has left the
Chocolate Room the program will:
o ask the player to try to
remember any of the letters
they were given in the game
o ask the player to try to guess
the password using the clue
and the letters they already know
o calculate and show the player their score.
➤ Add the lines of code that are missing from this section of the program. You can do
this by editing ad63.py provided by your teacher.
➤ Run the program and correct any errors.

124

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 124 27/04/20 1:59 PM


Unit 8.4 High level programming language: Expert story telling

Final project
You are going to create a game in Python, for 10–11 year olds to learn their times tables.
Players will be asked 12 multiplication questions and their score will be calculated. You will use
the skills you’ve learnt in this unit.
➤ Open the game FINAL.py, provided by your teacher, and look at the code. Use this
code to look at when creating your new project.
The game should have the following features.
➤ An introductory screen with information about the game.
➤ A section of code, containing a while loop, to allow the user to
Hint: look at
input their name. the example of
➤ A section of code, containing a while loop, to allow the user to combining conditions
input their age. The player’s age must be between 10 and 11. on p106 to help
➤ A section of code to print a welcome message including the you.
player’s details onto the screen.
➤ A section of code which asks the child which times tables they want to try. Store this
in a variable called tables.
➤ A while loop in which a variable called number goes from 0 to 12
● A section of code which prints out number * tables as an equation,
with a question mark. For example: What is 5 * 5?
Note that all
● A section of code to calculate the result of multiplying the variable
of this code
number by tables; use an assignment to store the result of this should be
calculation in a variable called result. indented
● A section of code to allow the user to input their answer to the so that it is
question, stored in a variable called answer. Do not forget to inside the
while loop.
use int() with the input statement.
● A section of code, containing an IF statement, which checks to
see if the answer equals the result. If the result and the answer
are the same, then the player’s score is increased by 1.
➤ A section of code to output the player’s score and a message stating that the
program has ended.
Run your game and correct any errors.

Evaluation
➤ Ask a friend to play your game and comment:
o is it fun and enjoyable? (give two examples)
o is it easy to use?
o are the messages easy to understand?
o are the final scores correct for the pupil? (they should check the calculations and
keep a written record of each answer to see if the code is working correctly).
➤ Open your program and look at the code. Reflect on how you have used:
o comments to improve readability
o validation to ensure data is acceptable.
➤ Based on the evaluations, make a list of recommendations to improve your game.

125

481992_U4_Int_Com_Low_Sec_SB_095-125.indd 125 27/04/20 1:59 PM


Unit Spreadsheet modelling:
8.5 Model my merch
Spreadsheets
Spreadsheets can be used to help analyse data
and improve how it is presented. A spreadsheet
can perform calculations automatically and,
if the values are changed, it can work out the
new results automatically. This is an advantage
because it means that you can try lots of
values and see what the new results are. As the
calculations are done so quickly, you can spend
time looking at the new results and thinking
about how changes to the data can affect it. In
other words, you can predict what would happen if you made certain KEYWORDS
changes. Spreadsheets can be used to collect and store large amounts absolute cell
of data in rows and columns. We make use of abstraction techniques reference: a cell
reference that remains
to view necessary data. For example, the data can be searched, sorted constant even if it is
or filtered so that unnecessary data is hidden and only relevant data is copied to other cells
displayed on the screen. conditional
formatting: applying
Big Data is collected by the many devices on the Internet of Things (IoT). formatting such as
The devices generate a lot of data that can be used to make them useful colour to a cell based
on certain criteria
but it can also be analysed for other purposes. For example, your mobile named cell range:
phone constantly broadcasts information about your location. Smart giving one cell or a set
watches collect information about fitness levels and exercise patterns. of cells a name; the
Most data collected by the IoT is stored in a form that can be used in cells can be referred
to using the name
a spreadsheet. The data can then be analysed to provide information. assigned
For example, business owners may want to know the number of users of data modelling: using
their website, smart city lighting may collect data on electricity usage, mathematical functions
and data about our spending habits can be analysed so that we receive and calculations on
data to predict or
messages on our smartphone about products we like. model what may
happen in the event of
In this unit you will learn to: certain changes
➜ use the features of a spreadsheet to solve problems IF statement: a
➜ use the following advanced features of a spreadsheet: absolute cell statement which
evaluates a condition
references, conditional formatting, validation, named cells and places one value in
➜ build more sophisticated formulas and use in-built functions to carry the cell if the condition
out calculations is true and another
value in the cell if the
➜ use aspects of data modelling including IF statements and lookup
condition is false
statements lookup statement:
➜ use nested IF statements Used to search
through a table of
➜ validate input using presence, length, range and type checks.
data for a value and
➜ sort and filter contents of a spreadsheet then return results if
that value is found

126

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 126 27/04/20 2:20 PM


Unit 8.5 Spreadsheet modelling: Model my merch

➜ link data between worksheets using formulas KEYWORDS


➜ create and use macros to automate tasks nested IF statement:
➜ understand how spreadsheets can be used as a modelling tool to an IF statement
support basic decision making. which is embedded in
another IF statement
presence check: a
KEYWORDS
validation check which
sort: to change the order of data; for example, data can be sorted in is used to ensure
alphabetical order or numerically that there is a value
filter: A spreadsheet feature which allows the user to apply certain criteria and entered. A length
exclude or show certain data check can be used to
macro: a small program which is used to automate a task do this; for example, a
check to ensure that
the value entered has
Microsoft Excel 2016 has been used to complete the examples in this at least one character
unit. You can also complete the examples in a spreadsheet application length check: a
of your choice, such as Google Sheets or LibreOffice Calc. validation check which
is used to ensure that
the value entered has
a particular number
SCENARIO of characters; for
You are a new employee in a local skate park, called Wreck Deck Skate example, a check to
ensure that a name
Park. The owners, Văn and Hoa have just opened a merchandise has at least five
store and want you to create a spreadsheet to help them keep track characters
of the sale of goods. The store is going to stock a small selection of range check: a
products including T-Shirts, skateboards and scooters. As you have validation check which
is used to ensure that
some knowledge of spreadsheets, the owners have asked you to the value entered lies
prepare a spreadsheet which will help them make decisions about within a given range;
their business. for example, 1–100
type check: a
validation check which
is used to ensure that
Do you remember? the value entered is of
a certain data type; for
Before starting this unit you should be able to carry out the example, a check to
following in Microsoft Excel: ensure data is numeric

✔ Select an appropriate data type for data in a spreadsheet.


✔ Format data to improve its presentation.
✔ Write simple formulas to help analyse the data.
✔ Display a spreadsheet in formula view.
✔ Use the chart feature to create visual information.

127

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 127 27/04/20 2:20 PM


International Computing for Lower Secondary

Using conditional formatting and validation

Learn

Conditional formatting allows you to Conditional formatting applies the


create rules for a range of cells so that they specified formatting only when certain
are formatted in a certain way depending conditions met. It can be used to visually
on their value. This is useful if you want show when data is following or breaking
to highlight key data in the spreadsheet. a rule.
This is a form of abstraction as conditional
For example, the spreadsheet below
formatting can filter out data by making it
shows a simple timesheet for Hoa’s staff
less visible to the user.
and highlights any staff member who is
For example, you can make a cell appear working more than 40 hours per week, as
bold if the value of the cell is greater than the company does not permit this.
20, or you can make a cell appear red if it
contains the word ‘T-Shirt’. Being able to Staff ID First Name Surname Hours worked
format data in this way makes it easier for this week
the user to draw conclusions and make 123 L. Chang 32
decisions. 124 M. Ng 41
A copy of the products sold in the shop is 125 R. Wan 42
shown below. 126 D. Chang

You can also compare rows based on


a single value. For example, the table
below shows staff with the name ‘Chang’
highlighted.

Staff ID First Name Surname Hours worked


this week
123 L. Chang 32
124 M. Ng 41
125 R. Wan 42
126 D. Chang

Hoa wants to see all of the items that cost


more than $20.00 because he is worried
about the shop’s profit. Conditional
formatting can help to do this. In this
case the rule would be: ‘cells greater than
$20.00’.

128

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 128 27/04/20 2:20 PM


Unit 8.5 Spreadsheet modelling: Model my merch

To do this:
1 Home Tab » Style group » Conditional
Formatting dropdown » Highlight Cell
rules » Greater Than…
2 Enter $20.00 in the Format cells box
and click OK.
3 After clicking OK, the cells with values
more than $20.00 are highlighted with
Light Red Fill and Dark Red Text.
There are a number of different ways to
use conditional formatting.
Data Bars show data values relative to
each other as data bars. This is useful
to see how each value compares to the
largest value.
Top/Bottom Rules allow the user to
highlight the top and bottom values, for
example, the top 10%.

Practice

You are going to add some data about the products for sale in the shop. This data
is needed so that products can be kept in stock and re-ordered when needed. Each
product has its own re-order level and re-order quantity. If an item falls below its re-
order level then it must be re-ordered. For example, 30 Large T-shirts must be ordered
if the quantity in stock falls to 40 or below. Conditional formatting could help Hoa see
immediately all of the items which need to be re-ordered.
➤ Open the file WDSP1.xlsx, provided by your teacher.
➤ Go to cell D5 and enter a formula in the formula bar for the Selling Price of a Helmet.
This is calculated by multiplying the Cost Price by 1.2. Remember to enter the ‘=’
symbol first. If you have done this correctly, the value $49.19 will appear in cell D5.
➤ Copy the formula down to each of the cells from D6 to D20. To copy the formula, go to
cell D5 and drag down.

129

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 129 27/04/20 2:21 PM


International Computing for Lower Secondary

➤ Look at the formula in each of the cells D5 to D20. Microsoft Excel has automatically
adjusted the cell reference in the original formula for each cell. Relative addresses are
used. For example, in cell D5, the formula is based on cell C5, in cell D6 the formula is
based on cell C6 and so on. The correct answers will automatically appear in column D
‘Selling Price’.

The fill handle is a


small dot or square in the
bottom right corner of the
active cell; it can be used to
copy the contents of a cell to
drag the formula down through the cells using the adjacent cells, fill cells with
fill handle at the bottom of cell D5 numbers or labels,
and copy formulas.
➤ Enter the following text and values in columns E, F, G and H.

➤ The owners of the shop want to see which products are not selling well. Use
conditional formatting to highlight, in green, all the items where the Quantity in Stock
is greater than 30.
o Highlight cells E5 to E20.
o Select Conditional Formatting and use the Highlight Cells Rules.
➤ Selling prices are to be reviewed this year and the owners want to know about the
highest and lowest priced items. Use the Top/Bottom rules to highlight the highest
selling price for an item and the lowest selling price for an item.
➤ Văn needs to check the re-order quantity and he needs to compare them to each
other. Use the Data Bars conditional formatting to give Văn a visual representation of
this information.
➤ Look at the spreadsheet with conditional formatting. Is it easier to understand?

130

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 130 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Data validation

Learn

Data validation allows you to set up rules which control the values KEYWORD
or text that can be entered into a cell. When you use validation it
data validation: the
prevents the entry of data which is unacceptable. The validation process of checking
feature also allows you to provide helpful error or feedback data entered to ensure
messages to the user. This can help them to enter data in the that it is acceptable
correct form. Data validation can provide the following checks:
Range check Ensures that data entered is in the correct range.
Type check Ensures that data entered is the correct type. For example, a text value cannot be entered
if a number is required.
Presence check To ensure that data is entered.
Length check To ensure that the data entered has a certain number of characters.

Văn knows that the maximum cost of the products that are sold in the shop is $150.00.
He wants you to create a validation rule that will ensure that no values outside of the
range $0.00-$150.00 can be entered into cells B5 to B20. Văn needs a range check.
To create a validation rule:
1 First select the cells that you wish to create
the rule for, B5:B20.
2 Choose Data Tab È Data Tools È Data
Validation
The Data Validation dialog box will be
displayed.
3 There are three parts to this box: Settings,
Input Message, and Error Alert.
Settings is where you enter the validation
criteria or rules.
➤ Choose an option from the Allow drop-
down menu – in this case we allow decimal
values. A decimal value is a number containing a decimal KEYWORDS
point. For example, 20.9. input message: a user
defined message which
➤ Choose an option from the Data drop down menu – in this will appear when the
case we select 'between' as we are creating a check for a user is entering data into
range of values a cell
error alert: a user
➤ The Minimum and Maximum boxes will allow us to enter the
defined message that will
range (0–150) for the acceptable values. appear when the user
enters data that breaks
Input Message allows you to set a message here which will help the validation rule
the user when entering the data. The input message will appear
when the cell is selected. Give an example of an
Error alert allows you to specify an error message using the Error error alert message you
Alert. The message will appear in a message box. recently received.

131

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 131 03/05/20 8:42 PM


International Computing for Lower Secondary

Entering a value of
170 will trigger the
error alert.

Functions are
It is important that data entered is of the correct data type. small programs which
To do this you can create a custom validation rule which will are written to carry out a
check for different data types. For example, in the case of specific task. A function will
the product code you would not want to have letters in the return a value which can
Product Code. be used to control what
Microsoft Excel provides functions to check for data types, happens next in
two of which are a program.

ISNUMERIC(), which checks a cell value to


ensure it is numeric. It returns a value of TRUE if
the cell value is numeric and FALSE if it is not.
ISTEXT(), which checks a cell value to ensure it
contains text. It returns a value of TRUE if the
cell value is numeric and FALSE if it is not.
To add a data type validation for Product Code:
➤ select custom in the Allow drop-down menu
➤ add the formula =ISNUMERIC(A5:A20)
➤ add suitable input and error messages.

132

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 132 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Practice

➤ Continue using the file WDSP1.xlsx, provided by your teacher.


➤ Create a validation rule for the Re-Order Level cells so that they are always between 0
and 100.
o Highlight all of the values in the column.
o Then select Data Tab» Data Tools » Data Validation.
o Complete the three sections of the data validation dialog box.
➤ Create a further validation for the Re-Order Quantity cells to ensure that the value
entered is always between 10 and 50. You should highlight all of the cells and complete
all of the sections of the data validation dialog box.
➤ Test your validation rules by trying to enter the following:
o Go to cell F7 and change 100 to 150. What happens?
o Change the value in F7 back to 100.
o Go to cell G7 and change 50 to -5. What happens?
o Change the value in G7 back to 50.
➤ Create a validation rule for cells B5:B20, which contains a length check to ensure that
the Product Description is at least four character’s in length and no more than thirty
characters in length. You can do this by selecting Text length from the Allow drop
down menu and adding the maximum and minimum length in the validation criteria.
Do not forget to add suitable input and error messages.
➤ Select cells B5:B20.
➤ Add a validation rule by:
o selecting ‘Text Length’ in the ‘Allow’ box
o entering the Minimum and Maximum length for the product description.
➤ Test your validation rule by:
o changing the text in B6 from ‘Pads’ to ‘Pad’ (what happens?)
o changing the text in B6 back to ‘Pads’.
➤ Add a type check validation for the Product Description to ensure that only text can
be entered. Remember to select cells B6:B20 first and use the ISTEXT() function. Test
your validation rule to see if it works.

133

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 133 27/04/20 2:21 PM


International Computing for Lower Secondary

Using absolute cell references and named cell ranges

Learn

Using named cells in formulas


Named cells or cell ranges can be used as an alternative to cell references. In a formula, a
named cell is the same as a cell reference but it is normally used for values that are used
a number of times in different formulas.
When we use named cells it is similar to using a variable in a program.
The computer will set aside an area in memory for the named cell and
its value. Just like variables, if we want to use the value in the named
cell we simply use the cell name.
Look at the formula in the cells, right. The Selling Price is calculated by
multiplying the Cost Price by a value, which we will call the Markup Rate.
The Markup Rate is currently 1.2.
That means the Selling Price is 20% greater than the Cost Price.
What if the Selling Price is now calculated by multiplying
To display the Cost Price by 1.3 instead of 1.2? How many
the formulas on a
changes would have to be made to the formulas on
spreadsheet select
the spreadsheet?
Formulas Tab » Formula
Auditing Group » Show You would need to change all of the formulas in the
Formulas. Selling Price column. Using a named cell can help
improve the efficiency of the spreadsheet when making changes.
If the Markup Rate is held in a named cell, only one change would be needed. The
Markup Rate is entered in cell C24 and given the name Markup, as shown.

To create a named cell, click on


the cell you want to name (in this
case C24) and type the name in
the space where the cell reference
appears.

KEYWORDS
named cell: a name given to an individual cell in a spreadsheet
selling price: the price at which a product is sold to customers
cost price: the price at which a product is bought by the store owner

134

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 134 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Update the formula in cell D5 so that it reads:


=C5*Markup
Using the fill handle, this formula is copied down to each cell in
the column. When the formula is copied down, the reference
to the named cell does not change.
The formulas in column D now look like the screenshot, right.
If the value in cell C24, now called Markup, is changed all of
the values in the column are automatically adjusted. If the
markup changes in the future, then only one change to the
spreadsheet is needed – this is much more efficient.

Absolute cell reference


Absolute cell references are another way of referencing
individual cells in a formula.
Văn wants to estimate the tax paid on each item. At present
tax is paid at a rate of 10% on the Cost Price. The tax rate of 0.1
has been added to the spreadsheet in cell C25. A new column
Tax Paid is added to column I.

Note that when the formula is copied, the answers are incorrect.
To calculate the tax paid on a helmet, the following formula is used in cell I5:
= C5*C25

135

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 135 27/04/20 2:21 PM


International Computing for Lower Secondary

However, when this formula is copied down to cells I6 to I20, the


results are incorrect. Look at the formulas, right. What is wrong with
them?
Each formula should be multiplied by the tax rate which is held
in cell C25. However, Microsoft Excel has automatically changed
the cell reference for each row. Read the section on relative cell
references above to remind you about this.
In this case we do not want the cell reference to change so we must
use an absolute cell reference. This is done by adding a $ symbol
to the row and column of the cell reference (or pressing F4). So, in
cell I5, the reference to C25 becomes $C$25. The formula in cell I5 is
now:
=C5*$C$25
When a formula containing an absolute cell
The formulas
reference is copied or dragged down, the
in column I are now correct.
absolute cell reference will not change.
To see the results of the
calculations simply turn off the Both named cells and absolute cell
formula view: Formulas Tab » references make spreadsheets more
Formula Auditing Group » efficient as they reduce the number of
Show Formulas. changes to formulas. They allow users to
change one value and all the cells
that use that value are automatically
updated. This means that they can
If the tax rate instantly see how changes of
changes then only the value values affect the overall results
in cell C25 needs to be in the data. For example, Văn
changed. All of the results in
and Hoa could try changing the
the ‘Tax Paid’ column
Markup value to predict the
will be updated
automatically. effect this would have on the
selling price for each item. This
is a form of data modelling.

136

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 136 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Practice

The shop at Wreck Deck Skate Park is becoming very popular and Văn is thinking about
selling on a website. He wants look at how different currencies would affect the selling
price. Also, if he is selling online, he will have to charge postage. Văn has produced the
following information:

➤ Open the spreadsheet WDSP3.xlsx, provided by your teacher.


➤ Văn thinks that he could sell the merchandise to some European countries and wants
to know about the Euro (€) conversion rate. Use the internet to research today’s Dollar
to Euro conversion rate.
➤ Văn decides to use 0.90 as the Dollar to Euro conversion rate. Enter this value in cell
C26.
➤ Create a formula in cell E5 which will calculate the Selling Price in Euros for each
product.
➤ Change the formula in cell E5 so that C25 is an absolute cell reference.
➤ Copy the formula in cell E5 into cells E6 to E20.
➤ Check your answers against Văn’s information.
➤ Format the cells in E5 to E20 as currency.
➤ Try changing the Euro conversion rate and observe the effect on the values in cells E5
to E20.
A number of local customers have asked Hoa about having products delivered to them.
She has a small truck and she thinks that she could deliver to customers within a 5
kilometre radius. She wants to see what she would have to charge for delivery. After
talking to Văn they decide that they would charge $4 for delivery plus 5% of the cost of
the item.
➤ Enter $4 into cell C27.
➤ Name cell C27 ‘DeliveryCharge’. You can do this by clicking on cell C27 and typing the
words ‘DeliveryCharge’ into the name box.

137

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 137 27/04/20 2:21 PM


International Computing for Lower Secondary

Decomposition

✪ You will use decomposition to break problems down into smaller


problems.
✪ You will have to create a formula which completes both aspects
of the calculation.
o Firstly, find 5% of the cost price of the product.
o Secondly, add $4 to this cost.
✪ Create a formula in cell F5 which will calculate the Local Delivery
Fee for a Helmet. Use the named cell ‘DeliveryCharge’ in your
formula.
o Copy the formula to cells F6 to F20.
o Change the value in cell C27 ‘Delivery Cost’ to $5. Look at
the impact that this has on the values in column F.
o Change the value of the Tax Rate so that Hoa pays at least
$10.00 tax on every item.
o What value did you reach for the Tax Rate?
o Compare this with the Tax Rate used by a classmate. Why
are your values different?
o Set the Tax Rate back to 1.2.

Using built-in functions to carry out calculations

Learn
KEYWORDS
built-in functions:
Microsoft Excel has many built-in functions which can be
functions that exist
incorporated into formulas. Some of the most common functions within the software for
include the SUM function which adds up the values in a cell use by the user
range and the AVERAGE function which will find the average arguments: values
value in a cell range. that are passed to
the function in the
Most functions in Microsoft Excel require some information brackets that follow
to carry out their task. The information which you give to the the function name;
function is called an argument. A function generally returns a these values are used
value that can be used later. within the function

For example, the SUM function requires a cell range as an


argument. In the formula:
=SUM(C5:C20)
the argument for the SUM function is the cell range C5:C20.
The general format of a function call is:
FUNCTIONNAME(argument1, argument2,.....)
There are two stages to complete when inserting a function:
Stage 1: Select the function you want to insert, and Stage 2: Add
the Function Arguments.

138

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 138 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Stage 1: Select the function you want


to insert
Click on the fx symbol in the formula
bar. The ‘=’ symbol will be inserted
automatically and the Insert Function
window will appear.
You can then search for a function or
select from a list of functions.
Stage 2: Add the Function Arguments
An argument is an actual value that is
passed to the function at the time when
it is called. An example of this is the cell
range which it has to search through. (In
programming, data can also be passed into
functions or procedures using parameters.
Parameters are variable names rather than
actual values.)
For example, to find the maximum number
in the cell range I5:I22, insert the MAX
function. The function arguments are
the cell range which will be used by the
function. This screenshot shows how.

Algorithmic thinking

How would the Maximum function work in pseudocode?


SET MAX= 0
For each CELL in the range I5 TO I22
IF VALUE IN CELL > MAX
MAX = CELL VALUE
ENDIF
END FOR
RETURN MAX

139

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 139 27/04/20 2:21 PM


International Computing for Lower Secondary

Another way of inserting a function


As well as inserting a function using the fx symbol, you can use
any function by entering its name after the ‘=’ symbol in the
formula bar. Then open brackets, enter the argument and close
the brackets.
Whilst many functions have one or more
arguments, some functions do not have any.
For example, the NOW() function which
returns the current date and time does not
need any arguments.

To browse through all of the functions


available in Microsoft Excel, click on the fx
symbol and select All from the category
drop-down list. (There are a lot of different
functions and it might not be clear what
each one of them does.) Alternatively, you
can browse by categories such as Statistical
functions or Date and time functions.

Practice

The owner of the shop wants to use some summary data relating to the spreadsheet. He
needs average prices and wants to know how much money the stock is worth.
➤ Open the spreadsheet called WDSP4.xlsx, provided by your teacher.
➤ Using the insert function feature add the following:
o In cell C21, a formula to find the average Cost Price.
o In cell D21, a formula to find the average Selling Price.
o In cell F21, a formula to find the average Local Delivery Fee.
Hoa is worried about the amount of stock that is stored at the shop. She wants to know
how much the stock is worth in total and has asked you to calculate this value. The
value is calculated by multiplying the Selling Price by the number of items in stock. For
example, the stock value for Helmets is:
$49.19*50 = $2459.40
➤ Go to cell L5 and enter a formula which will calculate the Stock Value for Helmets.
➤ Copy the formula down to cells L6 to L20.
➤ Go to cell L21 and insert a formula containing the Sum function which will calculate the
total value of the stock in the shop.
➤ Save the changes to the file WDSP4.xlsx.

140

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 140 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Testing conditions using the IF function

Learn

The IF function can put one of two values in a cell depending on the outcome of
evaluating a condition.

Relational operators in Microsoft Excel Look back at


Equal to = section 8.4 to remind
yourself about IF
Not equal to <>
statements. These are
Less than < used to select which
Greater than > statements will be
Less than or equal to <= executed.
Greater than or equal to >=

In order to keep the store stocked properly, you need to know which items need to be
re-ordered. Văn has told you that when the quantity in stock for a product falls below its
re-order level, it must be re-ordered at the next possible opportunity.
You need to include a formula in the spreadsheet to identify those items that need to be
re-ordered based on how many of them are in stock. Consider creating this formula for
the Helmets in row 5. Column J will contain the IF function determined by the condition:
Quantity in Stock is less than or equal to the Re-Order Level
In terms of cell references this condition is:
G5<=H5
If the condition is true (the number of helmets in stock is less than or equal to the
re-order level), then the formula should place a Yes in the relevant cell.
If the condition is false (the number
of helmets in stock is greater than
the re-order level), then the formula
should place a No in the relevant cell.
➤ To enter the formula for a Helmet,
make sure the active cell is J5.
➤ Using the insert function feature,
select the IF function.
➤ In the Logical text box enter the
condition G5<=H5.
➤ In the Value if true box, place the
value that you wish to appear in
the cell if the condition is true. In
this case, Yes.
➤ In the Value if false box, place the
value that you wish to appear in
the cell if the condition is false. In
this case, No.

141

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 141 27/04/20 2:21 PM


International Computing for Lower Secondary

➤ Note that quotation marks are added to the text automatically. Click OK.
The IF statement appears in the formula bar as shown. The outcome from the IF
statement is now shown in cell J5.

Algorithmic thinking
The general format of an IF statement is

Algorithm Spreadsheet equivalent


IF condition IF logical test
THEN action 1 Condition if true
ELSE action 2 Condition if false
endif -

The algorithm for this particular example could be


IF G5 <=I5
THEN PLACE YES IN CELL
ELSE PLACE NO IN CELL
ENDIF

142

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 142 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

The formula must now be copied down to cells J6 to J20.

Pattern recognition
When you copy a formula to other cells there are similarities
between the formulas in each cell.

Look at the first few formulas in Column J. What are the


similarities and differences between the formulas in each cell?.

Using nested IF statements


If you need to test for more than one condition, and then take one of several actions based
on the result of the test, you can add multiple IF statements together in one formula.
These are known as nested IFs because one IF function is contained within another.
Văn wants to keep track of the total stock value in the shop. He has decided to take
action based on the value of the stock. Here is a table showing the actions he will take
based on the total stock value.

Stock Value($) Action


0–15999 No action
16000–21999 Check high value items and report
22000 and over Reduce the number of high value items in store

Văn wants the actions to show on the spreadsheet when he opens it so that he doesn’t
forget about them. He has decided to put the message in cell B30.
We can use nested IF statements to solve this problem.
To build up a nested IF formula that will do this,
➤ Start by testing to see if the stock value is below 16000.
➤ If TRUE, we return ‘No Action’. If FALSE, we move into the next IF function.
➤ Next test to see if the score is less than 22000.
➤ If TRUE, we return ‘Check High Cost Items and Report’. If FALSE, we ‘Reduce the
number of high value items in store’.
The total stock value is held in L21. The formula to be entered into cell L25 will be:
=IF(L21<16000,”No Action”,IF(L21<20000,”Check High Value Items and
Report”,”Reduce the number of high Value Items in store”)).

143

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 143 27/04/20 2:21 PM


International Computing for Lower Secondary

Algorithmic thinking
The algorithm to solve Văn’s problem is:
IF TOTALSTOCKVALUE < 16000
OUTPUT “No Action”
ELSE IF TOTALSTOCKVALUE < 21999
OUTPUT “Check High Value Items and Report”
ELSE OUTPUT “Reduce the number of high
Value Items in store”
ENDIF
ENDIF
Match the algorithm to the formula.
Algorithm Formula
1 IF TOTALSTOCKVALUE < 16000 =IF(L21<16000
2 THEN OUTPUT “No Action” ,”No Action”
3 ELSE IF TOTALSTOCKVALUE < 20000 ,IF(L21<20000
4 THEN OUTPUT “Check High Value Items and Report” ,”Check High Value Items and Report”
ELSE OUTPUT “Reduce the number of high Value Items in
5  ,”Reduce the number of high Value
store” Items in store”))
In the formula, THEN and ELSE are represented as commas.

It is important to move in one direction, either low to high, or high to low. This allows us
to return a result whenever a test returns TRUE, because we know that the previous tests
have returned FALSE.

Decomposition and Generalisation


You will use decomposition to break a large problem into smaller more manageable
problems. You will use the experience that you have gained to help you solve these
problems. This is generalisation, when you use your experience in one problem solving
exercise to help you with another.
✪ Continue using WDSP4.xlsx.
✪ Hoa wants to classify the products in terms of the stock value.
o Products worth more than $1500 will be classified as High Value.
o Otherwise stock will be classified as Normal Value.
Hint: you
o With a partner, write down the condition that will solve this problem. must use a condition
o Use cell references in your condition. which checks to
✪ Review your condition and create an IF statement for cell M5 which will see if the value in the
assign the correct value to the cell given the stock value for Helmets. cell is greater
than 1500.
✪ Go to cell M4 and enter the text ‘Value’.

144

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 144 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

✪ Go to cell M5. Enter your formula into cell M5.


✪ Check the value in cell M5 to ensure it is correct.
✪ Now copy the formula down to cells M6 to M20.
✪ Look at the spreadsheet in formula view and review column M. Identify the similarities and
differences between the formulas in each of the cells M6 to M20.
✪ Văn wants to change the stock value boundaries for the actions he will take. He has come
up with a new table. Add an IF statement to cell B30 which will place the correct message
in this cell based on the new values.

Stock Value($) Action


0–17049 No action
17050–19999 Check high value items and report
20000 and over Reduce the number of high value items in store

Practice

You are going to use the COUNTIF function. This function counts the number of cells that
meet certain criteria. For example, =COUNTIF(A1:A20, “London”), counts the number of
cells with the word ‘London’ in cells A1:A20.
➤ Add a formula to cell H25 containing the COUNTIF function which will count the number of
products which need to be re-ordered. (Hint: you need to consider the values in column J.)
➤ Add a formula to cell H26 containing the COUNTIF function which will count the number
of high value products stored in the shop.

Filtering and sorting the contents of a spreadsheet

Learn

Filtering data
Filtering data in Microsoft Excel refers to displaying only the rows that meet certain
conditions. The other rows get hidden.
Using the shop data, if you only want to see all the products which need to be re-ordered
then you can set a filter to do this.
➤ Highlight cells A4 to M20
➤ Choose Data Tab » Filter to set filter. The drop-down arrows will appear beside the headings.

145

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 145 27/04/20 2:21 PM


International Computing for Lower Secondary

➤ Click the drop-down arrow in the Re-Order Yes/No column.


➤ Remove the check mark from Select All, which unselects everything.
➤ Then select the check mark for Yes which will filter the data and display only those
products that need to be re-ordered.

➤ Part of the spreadsheet is shown. Note that some of the row numbers are missing;
these rows contain the filtered (hidden) data.

The drop-down arrow in the Re-Order


Yes/No column now shows a different
graphic – an icon that indicates the column
is filtered.

Using multiple filters


You can filter the data using multiple conditions.
Suppose after the re–order list is shown, you want
only to see those products that are classified as
High Value. After setting the filter for Re-Order
Yes/No, click the arrow at the top of the Value
column and select the filter ‘High Value’ as shown.
You can see the two columns which have been filtered
as they have the filter icon beside the heading.

To clear the filters, choose Data Tab » Filter or tick “Select All” in the filtered columns.

146

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 146 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Sorting data
Sorting data in Microsoft Excel rearranges the rows based on the contents of a particular
column. For instance you may want to sort data in alphabetical or numerical order. To do
this:
➤ Select cells A5:M20
➤ Choose either:
• Data Tab » Sort, or
• Home Tab » Sort & Filter
The dialog box below appears.
➤ Select the field (column name) on which you want to sort. In this case, we want to sort
products according to their name, so choose Product Description.

➤ Click OK. The data is now sorted on Product Description.

You can sort data on more than one column in a spreadsheet. For example Văn wants to
see all items ordered by their Value and then Stock Value.
To perform a sort like this, we need two levels added to the sort. Level 1 will contain the
first sort on Value, and level 2 will contain the second sort on Stock Value.

147

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 147 27/04/20 2:21 PM


International Computing for Lower Secondary

You can Sort based on the following conditions:


➤ Values (alphabetically or numerically)
➤ Cell color
➤ Font color
➤ Cell icon

Practice

You are going to review the data about stock that needs to be re-ordered. Văn wants to
see which have the most stock left and which items have the lowest re-order level. He
may stop selling these items as they may not be selling well.
➤ Open the spreadsheet WDSP5.xlsx, provided by your teacher.
➤ Sort the data by Quantity in Stock, then by Re-Order Level. Ensure the result shows
the data in the order as required by Văn.
➤ As part of your data analysis you need to see all the products with a Cost Price less
than $20 that have between 12 and 45 products in stock.
o Set a filter on the Cost Price column, which will show only data for the cells shaded
in pink.
o To do this, you will use the “Filter By Colour” option on the filter menu.
o Then set a filter on the Quantity in Stock column which will show only those
products which have between 12 and 45 products in stock.
Văn also wants to check that the more expensive items are selling. He needs to know if
items over $50 have sold well by checking how many of these high value products are left.
➤ Clear all filters.
➤ Set appropriate filters so that you can see all the products with a Selling Price of more
than $50 that have less than 20 items in stock.
➤ In the Sort window, use the Delete Level button to clear the previous sort criteria.
➤ Sort the data so that it is sorted on Selling Price and then Stock Value.

Abstraction
Abstraction is the removal of data that is not necessary for solving the problem. You have
provided Văn with more information about the prices of products. However he does not
need to see all of the data to help him understand how the business is running. Filtering
will remove unnecessary data to provide useful insights for Văn.

148

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 148 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Using Lookup tables

Abstraction
Vertical Lookup (VLOOKUP) tables provide data in the form of a list or a table. The data
can be searched and relevant information extracted from the table or list and returned. The
data returned can then be used to put data into a cell or a calculation. The user is normally
unaware of the VLOOKUP process that the software uses to perform the operation.

Learn
KEYWORDS
Vertical Lookup
The information in a VLOOKUP table is structured like any other (VLOOKUP) table: a
data stored in a database or in a file created by a program. Each table in a spreadsheet
column represents a different category of information, known which is be used to
as an attribute. Each row represents all the information about a lookup a value and
single record in the table. The row is called a tuple. return data to a cell in
the spreadsheet
Văn wants to classify products and will use their profit to do this. He VLOOKUP: makes
will use the profit value to assign a profit rating to each product. use of a lookup table
of data to match the
A VLOOKUP table can be used to for this. As Văn wants to contents of a cell with
monitor the profitability of his stock he has asked you to classify a value in the lookup
each product based on the amount of profit made. This is table
calculated by subtracting the Cost Price from the Selling Price lookup value: the
of each product. He wants to classify the products using the value used to search
through the lookup
following rules. table
attribute table array: the set
of data that will be
Profit Profit Rating searched using the
$0.00–$9.00 Little Profit tuple lookup value
$10.00–$19.00 Good Profit column index num:
Over $20.00 Highly Profitable the column number of
the data that will be
returned if there is a
A lookup table has been created in cells L25 to M27 in WDSP5b.xlsx. match for the lookup
value in the table array
Column 1 Column 2
0 Little Profit
10 Good Profit
20 Highly Profitable

The VLOOKUP function allows you to set up a range search. It


uses a value and compares the cell value to those in the table.
This is the VLOOKUP statement that will be used in cell O5 to
assign a rating to each product. The profit for Helmets has been
calculated and is stored in cell F5.
=VLOOKUP(F5,L25:M27,2)

149

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 149 27/04/20 2:21 PM


International Computing for Lower Secondary

The first argument in the VLOOKUP function is called the lookup value. There is a fourth
In this case it is the profit made from the product in cell F5. The second argument which is set
argument is the table array, which is the table containing the lookup to True if returning a
data. In this case the table array is located in cells L25:M27. The third partial match and False
if returning an exact
argument is the column index num, which is the value we are looking for.
match.
This VLOOKUP statement uses a value in cell F5 and checks through cells
L25 to M27 to see if the value in cell F5 is present. If the value is found, the
VLOOKUP function will return the matching value in column 2. But if the numeric value is
not found, the statement will return the next value in the table which is smaller than the
value being looked for.
Take care when copying the VLOOKUP formula:
=VLOOKUP(F6,L26:M28,2)
When the formula is copied down to cells O6 to O20 the results are incorrect. Open the
spreadsheet WDSP5b.xlsx, provided by your teacher. Go to cell O5 and examine the
formula which works perfectly.
Why do you think that the formula does not work in the other cells?
The lookup data is located in cells L25 to M27. Look at the formula shown. The reference
to the lookup data is wrong. Remember, when a formula is copied, that Microsoft Excel
automatically adjusts the cell references. How do we stop this from occurring?
We use absolute cell referencing. Change the formula in cell O5 to:
=VLOOKUP(F5,$L$25:$M$27,2)
Save this spreadsheet as you will use it in the practice exercise.
Then copy the formula down to cells O6 to O20. The results are now correct.
This VLOOKUP function can be used to help model different situations on the spreadsheet
and to predict outcomes if the data is to change. For example, the VLOOKUP table can be
used to determine profitability and the boundaries can be changed. Any changes made to
the boundaries will be reflected in the Profitability Rating column immediately.
An advantage of using formulas and VLOOKUP tables in spreadsheets is that any
changes to the data are reflected across all relevant calculations and functions.

Practice
➤ Use your updated version of the spreadsheet WDSP5b.xlsx.
➤ Go to the lookup table and make the following changes.
0 Little Profit
7 Good Profit
14 Highly Profitable Ensure that you
20 Extremely Profitable have included the
➤ Modify the VLOOKUP statement in cell O5 to include the new category. dollar symbols in the
correct places in the
➤ Copy the VLOOKUP statement in cell O5 to cells O6 to O20. formula.
➤ Check that the results are correct.
➤ Try changing the boundaries in the lookup table and review the changes made to the data.
➤ Save the file.

150

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 150 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Linking data between worksheets


Learn
Add a new
worksheet by right
You have been asked to include a further worksheet with sales data for clicking on the New
each product. Worksheet icon at
The new worksheet called Sales has been added to the spreadsheet the bottom of the
WDSP6.xlsx. spreadsheet.

The data for the products will be placed on the new Sales worksheet by linking
to the Products worksheet. This will save re-typing the data and also means that any
changes made to data in the Products worksheet will automatically be copied to the
Sales worksheet.
To link data to the Sales worksheet:
➤ Click on the Sales worksheet and go to cell A5. This is the destination worksheet.
➤ Type the = symbol.
➤ Click on the Products worksheet and go to cell A5. This is the source worksheet.
➤ Press Enter.
Check the formula bar (which displays the contents of the selected cell) at the top of
your workbook. For cell A5 in the Sales worksheet it should show the name of your
source worksheet, followed by an exclamation mark:

This means that cell A5 in the Sales worksheet contains the value of cell A5 in the
Products worksheet.
The formula in cell A5 of the Sales worksheet can now be copied to cells A6 to A20.
Linking data on worksheets helps save time and means that any changes in the Products
worksheet will be updated wherever that data has been linked.

Practice

Văn is now coming to a decision about the products that should continue to be sold and
those that he no longer wishes to sell. You are going to use VLOOKUP table to classify
the different products to help Văn make his decision.
➤ Open the spreadsheet WDSP6.xlsx provided by your teacher.
➤ Go to the Sales worksheet.
➤ Go to cell A5 and copy the formula to cells A6 to A20.
➤ Go to cell B5 and create a link to the Products worksheet to display the product
description in this cell. Review the instructions for linking data (above) to help you with
this.

151

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 151 27/04/20 2:21 PM


International Computing for Lower Secondary

➤ Copy the formula in cell B5 to cells B6 to B20.


➤ A lookup table has been created in cells N5 to O8 with the following information:

0 Stop Selling
100 Check Sales Weekly
200 Good Seller
Remember to
300 Best Seller use absolute cell
referencing for the
➤ Create a VLOOKUP statement in cell J5 which will return a Sales
lookup table before
classification for Helmets based on the Total Sold in cell I5. copying the
➤ Copy the formula in cell J5 to cells J6 to J20. formula.
➤ Review the results.
➤ With a partner, discuss how the data in column J could help Hoa and Văn when
selecting products to stock in their shop.

Challenge yourself

Create and use macros to automate tasks


A macro is a small program which is created to automate a repetitive task such as
printing a spreadsheet. The macro recorder can record a particular on-screen action and
then attach that action to a button. The button can then be placed on the spreadsheet
and pressed when the action is to be carried out.
A macro is required which will create a chart showing the Cost Price of each product.
➤ Open the spreadsheet WDSP8.xlsx, provided by your teacher.
➤ Choose View Tab » Macro dropdown.
➤ Click on Record Macro.
Select the
➤ Give the macro the name ‘CreateChart’ and click OK.
Insert tab and select
➤ Select the cells B4 to C20 and Create a Column chart for
the icon representing
the data. a column chart,
➤ Choose View Tab » Macro dropdown »Stop Recording. from the Charts
➤ Choose View Tab » Macro dropdown. Look at the macro code group.
generated by using the Record Macro feature.

152

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 152 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Abstraction
When you record a macro you can only see the function name (CreateChart) but
you cannot see the code behind the function. This is a form of abstraction as you
only see the information relevant to solve the problem.
The screen shot below shows the code and explains what each line means.
Can you map each line to your actions when recording the macro?

Select the cells Add a Column


B4 to C20 chart to the
spreadsheet

Use the cell range B4 to


C20 to create the chart

Now attach the Macro to a button.


➤ Choose Developer Tab » Insert dropdown.
➤ Click on Button (Form Controls).

➤ A small black cross will appear. Use this to draw the button on the spreadsheet.
➤ When you have drawn the outline of the button, the Assign Macro window will open.

153

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 153 27/04/20 2:21 PM


International Computing for Lower Secondary

➤ Select the CreateChart macro and click OK. The Macro is now assigned to the button.
➤ The button will appear on the spreadsheet.
➤ Change the text on the button to say ‘Create Chart’. To do this click on the text
currently on the button.
➤ The chart will appear on the worksheet. You can delete the chart and recreate it using
the button.
➤ Save the spreadsheet. (You must save the spreadsheet as a Macro enabled workbook
as you have added a macro into the workbook.)

154

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 154 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Go further

Using complex formulas


Open the spreadsheet WDSP7.xlsx, provided by your teacher.
Văn wants to calculate the income from each product using the sales figures. To do this
you will have to use data from the Products worksheet and the Sales worksheet.
You need the sales price for each product from the Product worksheet. To do this you
must set up a named cell range which is made up of the product data in cells A4 to 020.
◆ Highlight the cells in A4 to O20 in the Products worksheet.
◆ Whilst the cells are highlighted, type the word PRODUCTS into the name box. You
have now created a named cell range. You can refer to this table of data by its name
anywhere in the spreadsheet.

◆ To calculate the total income from each product you must break the problem down to
create a formula which uses a lookup statement and multiplies the value returned by
the lookup statement by another number.

◆ Go to the Sales worksheet.


◆ Add the appropriate text to cell K4.
◆ Format column K as currency.

155

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 155 27/04/20 2:21 PM


International Computing for Lower Secondary

◆ Create a VLOOKUP statement in cell K5 which uses the Product ID in cell A5 to lookup
the PRODUCTS table and return the selling price. From the data above, note that the
selling price is in the fourth column.
=VLOOKUP(A5, PRODUCTS, _ _ _ _ _ _ _ )
◆ Ensure your results are correct by comparing them to the ones in the previous
screenshot. Start by comparing your results in K5 to the results shown for K5.
◆ If you make any changes to the formula in cell K5, copy the formula down to cell K6 to
K20.
◆ Create a chart showing the Income from each product.
◆ Discuss how charts can help shop owners to manage their business.
◆ Go to cell C24 on the Products worksheet. Change the Markup rate to 1.4.
◆ With a partner, examine the entire spreadsheet and look at the changes that have
occurred as a result of making this change. Discuss how predictions can be made by
changing certain values in the spreadsheet.

Final project
Văn and Hoa have asked you to organise a promotional event for the store. You will have
to invite customers and provide them with food. There will be three events on three
separate evenings. There is a limit of 80 customers each evening. Customers will be
invited to try the new skateboards and will be given a goodie bag worth $6.00.
You must create a spreadsheet that will plan and manage expenditure. The spreadsheet
should allow Văn to try changing values so that he can manage his budget tightly.
He has a budget of $4000 for the three nights.
Remember
➤ Open the spreadsheet BUDGET.xlsx, provided by your teacher.
you can use the
➤ Complete the totals for each column using appropriate functions.
SUM function to
➤ Complete the values in column B. To do this use a VLOOKUP statement add the values in a
which uses the values in the table of prices in cells I10 to J19. range of cells.
➤ In the Number Required column, Văn has estimated how much of each type
of food he will need. He knows that not every guest will like Potato Chips and
has decided to order 40 bottles of water and 40 bottles of lemonade.
➤ Create a validation rule with suitable validation text which will ensure that the number
entered in cells C2 to C16 is between 0 and 80.
➤ Complete the values in column D.
➤ Complete the values in column E and use an absolute cell reference in your formula.
This will help with modelling later.
➤ Apply conditional formatting to all values in column E which are over $600.00. You
should highlight them in red.
➤ Apply a filter to the data to show only the values which are over $600.00.
An absolute cell
➤ Use an IF statement in cell E20 to determine if the party costs are over
reference contains
budget or not. $ symbols and does
➤ Record a macro which will create a Pie Chart of each item and the total not change when
cost for each item. copied.
➤ Add a button to the spreadsheet and assign the macro the button.
➤ Save the spreadsheet.

156

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 156 27/04/20 2:21 PM


Unit 8.5 Spreadsheet modelling: Model my merch

Evaluation

Once you have created your spreadsheet you can see that Văn
is over budget.
➤ You must look at the figures and make changes to the
spreadsheet to ensure that Văn does not over spend.
➤ With a partner, discuss what changes you would make. Try
modelling the changes in the spreadsheet so that Văn’s
spending does not exceed $4000.00.
➤ Together create a report, using a word processor, which will
tell Văn what changes need to be made to keep him within
budget. Your report should include:
o a short introduction telling Văn that he is over budget
and by how much
o a section detailing the most expensive costs
o a section detailing your recommendation for change
including two charts
o a conclusion explaining how much Văn will save.
➤ Share your report with another group. Ask them to read the
report and comment on:
o how easy it is to understand
o how the graphs and charts help them understand.
➤ Based on the feedback you have received make changes to
the report to improve its readability.

157

481992_U5_Int_Com_Low_Sec_SB_126-157.indd 157 27/04/20 2:21 PM


Unit Relational databases:
8.6 SegwayThere

Introducing relational databases


Microsoft Access 2016
Databases are used by organisations to help them manage is used in the worked examples
large quantities of data. The simplest databases look more like in this unit but other versions
large tables of information organised under a set of headings. of Microsoft Access can also be
used in this unit. Other examples
For example, this table shows an extract from a database of database software include
which records the details of some countries around the world. ADABAS and IBM Db2.

Country name Capital city Country Continent Continent size Continent


population in square miles population

India New Delhi 1,420,062,022 Asia 17,139,445 4,436,224,000


Brazil Brasilia 209,737,513 South America 6,880,706 422,535,000
Nigeria Abuja 200,962,417 Africa 11,677,239 1,216,130,000
Philippines Manila 108,106,310 Asia 17,139,445 4,436,224,000
Vietnam Hanoi 97,429,061 Asia 17,139,445 4,436,224,000
Germany Berlin 82,438,639 Europe 3,997,929 738,849,000
France Paris 65,480,710 Europe 3,997,929 738,849,000
United London 66,959,016 Europe 3,997,929 738,849,000
Kingdom
Saudi Arabia Riyadh 34,140,662 Asia 17,139,445 4,436,224,000
Peru Lima 32,933,835 South America 6,880,706 422,535,000
Canada Ottawa 37,279,811 North America 9,361,791 579,024,000
Australia Canberra 25,088,636 Australia 2,967,909 34,601,860
Taiwan Taipei 23,758,247 Asia 17,139,445 4,436,224,0

The table above is an example of a flat-file database. A flat-file


database is a database which uses only one table to store all of An error has been
the data. made when
recording the population
You can see in this extract from the database that the continent of Asia of Asia in this row of the
has been referred to a number of times. Compare the population of flat-file database.
Asia in the last row of this database with the other references to Asia.
Relational databases can help prevent this type of error occurring. If we
create a relational database we could use two tables to store this data.
Many developers will
use a special code when naming
KEYWORDS parts of a database. This can help
flat-file database: a database which stores all data items using one other developers tell one part of
table the database from the other. In
relational database: a database which stores data using two or this example, we will use _TBL
more linked tables to show these are tables.

158

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 158 27/04/20 2:37 PM


Unit 8.6 Relational databases: SegwayThere

country_TBL continent_TBL

country_ capital_ country_ continent continent continent_ continent_


name city population size_(sq_ population
miles)
India New Delhi 1,420,062,022 Asia Asia 17,139,445 4,436,224,000

Brazil Brasilia 209,737,513 South America Africa 11,677,239 1,216,130,000

Nigeria Abuja 200,962,417 Africa Europe 3,997,929 738,849,000

Philippines Manila 108,106,310 Asia South America 6,880,706 422,535,000

Vietnam Hanoi 97,429,061 Asia North America 9,361,791 579,024,000

Germany Berlin 82,438,639 Europe Australia 2,967,909 34,601,860

France Paris 65,480,710 Europe

United London 66,959,016 Europe


Kingdom
Saudi Riyadh 34,140,662 Asia
Arabia
Peru Lima 32,933,835 South America

Canada Ottawa 37,279,811 North America

Australia Canberra 25,088,636 Australia

Taiwan Taipei 23,758,247 Asia

Notice how ‘continent’ appears on both tables. It is the primary key


KEYWORD
field of the Continent Table (continent_TBL) but also appears in the
primary key field: a
Country Table (country_TBL). The ‘continent’ field provides a link field used to uniquely
between the two tables. Most database developers do not include identify a record in a
spaces in field names or table names; they use an underscore ‘_’ instead. database

When a continent name appears in the Country Table, the relational


database will look up the other details about that continent in the DID YOU KNOW?
Continent Table. Databases are used to
store large quantities of
In this unit you will learn: data and queries are used
to locate information
➜ the differences between a relational and a flat-file database
from database tables but
➜ how to describe the main features of a relational database queries can also be used
to perform calculations!
➜ to create and edit a relational database
We will see how to do this
➜ how to import data into an existing database structure later in this chapter.
➜ to create forms and reports to input and output data from a database
➜ how to use queries (QBE) to extract useful data from a database
➜ how to view and evaluate the SQL statements used to extract
data from a relational database and be able to create simple SQL
statements to extract data from a database.

159

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 159 27/04/20 2:37 PM


International Computing for Lower Secondary

SCENARIO
SegwayThere is a business renting Segways, electric scooters and safety equipment to tourists.
Customers can also buy safety equipment if they wish.
SegwayThere uses a number of tables of data stored in a number of different text files to keep track
of customers, bookings and equipment. Part of one of the text files used to store customer data is
shown below.

The owners were calculating bills for customers manually and giving them a A text file used
handwritten ticket as a record of each item they have rented or purchased. in this way is used only
This led to too many mistakes, was slow, and looked unprofessional. The to record data which
owners have asked you to set up a database to store details of their is typed in. The data stored
in a text file cannot be
bookings, customers and the items they have available for rental. They processed in
would like to be able to use this database to print a bill for customers. They any way.
would also like to be able to search the database for useful information.
When a customer rents equipment, they must provide identification such as a
passport, driving licence or student card. To make sure the different types of identification
don’t get mixed up, the company adds the letters PP to the beginning of all passport numbers,
DL to all driving licence numbers and ST to all student cards when they store the details.
Equipment will only be rented to people over the age of 18 and it can be rented out for more
than one day. The rental fee must be paid in advance.

Do you remember? KEYWORDS


field names: names
Before starting this unit, you should be able to: used to describe a
piece of information
✔ describe what a database is and some of the main uses of databases about a single person
✔ select appropriate field names and data types when creating or thing
database tables tables: organised
✔ create an appropriate primary key field for a database table collection of related
information
✔ be able to view database objects such as tables and queries query: a process of
✔ open an existing database and add a new field searching for data in a
✔ apply basic validation to database applications database
input mask: a special
✔ create and run simple queries to select data control used to ensure
✔ apply example input masks to ensure data is added in the correct data is entered in a
format. specific format; for
example, dates must
be entered as mm/dd/
yyyy

160

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 160 29/04/20 9:09 PM


Unit 8.6 Relational databases: SegwayThere

Why relational?

Learn

In databases, tables are used to store data in an organised way. Each table will have
a number of fields. In a database table, data is organised under a set of headings
called field headings. In the continent_TBL shown on page 159 we have three field
headings.

Continent continent_size_(sq_miles) continent_population three field headings


Asia 17,139,445 4,436,224,000
Africa 11,677,239 1,216,130,000
Europe 3,997,929 738,849,000
South 6,880,706 422,535,000
six records
America
North 9,361,791 579,024,000
America
Australia 2,967,909 34,601,860

Data stored in each table will be related in some way. For example, a table could hold
details on each of the Continents as shown above, or a database could include a table
which stores data on all of the customers of a shop, or all the products the shop sells.
Each row in a database table stores all of the data about a single person or thing. Each
row is called a record. The continent_TBL has six records.
Each table will have a special field called a primary key field. A primary key field is used
to uniquely identify each record. In contintent_TBL the field Continent could be used to
uniquely identify each record in the table.
When database tables are being created, each field can be designed
to store only a specific type of data such as text, numbers, date/
time. To help reduce the chance of errors occurring when data In some cases
a special format check can be
is being entered into a database table, the database can
applied using an input mask
also be designed to carry out validation checks. Validation
which makes sure that data being
checks help make sure that data being entered into the entered follows a specific pattern.
database table is, for example, of the correct data type, has For example an input mask
the correct number of characters. can be used to make sure
Some data may need to be recorded more than once in a a date is entered in the
mm/dd/yyyy format.
flat-file database. Unnecessary data duplication is called data
redundancy. Storing data twice can cause problems in databases,
such as taking longer to process data and output results, especially
if the databases contain a lot of data.
Mistakes can easily happen when data is recorded KEYWORDS
more than once in a large database. Mistakes cause data redundancy: the unnecessary
data integrity problems. In the example shown on the repetition of data in a database
next page an error has been made when entering the data integrity: the correctness and
continent for the last field in the table. accuracy of data in a database

161

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 161 27/04/20 2:37 PM


International Computing for Lower Secondary

country_name capital_city country_population continent


India New Delhi 1,420,062,022 Asia
Brazil Brasilia 209,737,513 South America
Nigeria Abuja 200,962,417 Africa
Philippines Manila 108,106,310 Asia
Vietnam Hanoi 97,429,061 Asia
Germany Berlin 82,438,639 Europe
France Paris 65,480,710 Europe A search for all
United Kingdom London 66,959,016 Europe of the records
relating to Asia
Saudi Arabia Riyadh 34,140,662 Asia
would not return
Peru Lima 32,933,835 South America
this record, and
Canada Ottawa 37,279,811 North America so the results
Australia Canberra 25,088,636 Australia displayed would
Taiwan Taipei 23,758,247 Azia be inaccurate.

Data tables can be linked by including the primary key field from one
table as a data field in another table. Some redundancy
Relational databases have two main advantages. is always necessary;
for example, in the continents
➤ Data is stored only once – this reduces data redundancy
and country example shown
and means the database will need less storage space. previously, the continent field
➤ Data integrity is improved – there are fewer chances for must appear in both tables
input errors as data items need only be entered once. to show how the data
is linked.

Abstraction

Most flat-file databases can be converted to a relational database format.


On the next page, you can see some of the data used by SegwayThere; the data is shown
in table format so it is easy to read. The first table, called Booking_Purchases_TBL, is
used to store details of customers and bookings. The second table, called Equipment_TBL,
is used to store details of the equipment they have available.
✔ With a friend, examine the Booking_Purchases_TBL structure. Decide how you can
split this table into two separate tables to reduce data duplication. Use the process of
abstraction to identify two separate groups of data in the flat-file shown. Think how
these two groups of data could be stored in two separate tables. What would the
tables be called?
✔ What would the primary key field be?
✔ What field would you use to link the second table to the first table?

162

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 162 29/04/20 9:09 PM


Unit 8.6 Relational databases: SegwayThere

Look carefully at the data items that have been


repeated. Think about what we did with the data items in
Booking_Purchases_TBL
our Country–Continent table at the start of this unit.

Cust ID Product
Number Title Surname Firstname Address 1 Address 2 Address 3 Country Number Age ID Date Out Date Back
120 Rue Des
1001 Mr Bisset Nicolas Flerus Bordeaux Aquitaine France DL908789 21 SW111 21/03/2020 24/03/2020
2916 Franklee
1002 Ms Feliciano Zelda Lane PN Pennsylvania USA PP656765 30 SW334 22/03/2020 22/03/2020
533 Ewald New
1003 Mr Ho Louis Crescent Claudelands Hamilton Zealand ST487614 18 SC009 22/03/2020 25/03/2020
1004 Mr Lue Benton Avendano 87 Alesanco La Rioja Spain PP028597 29 SW097 22/03/2020 28/03/2020
2132
1005 Mrs Iola Tovar St-Jacques Est Princeville Quebec Canada DL546763 20 SC128 23/03/2020 29/03/2020
2132
1005 Mrs Iola Tovar St-Jacques Est Princeville Quebec Canada DL546763 20 HEL122 23/03/2020 29/03/2020
2132
1005 Mrs Iola Tovar St-Jacques Est Princeville Quebec Canada DL546763 20 GLV675 03/04/2020 05/04/2020
Alcide De
1006 Miss Sloan Romona Gasperi 39 Arten Belluno Italy PP723456 18 SW765 23/03/2020 24/03/2020
1004 Mr Lue Benton Avendano 87 Alesanco La Rioja Spain PP028597 29 SW097 01/04/2020 02/04/2020
2916 Franklee
1002 Ms Feliciano Zelda Lane PN Pennsylvania USA PP656765 30 SW334 02/04/2020 10/04/2020
2132
1005 Mrs Iola Tovar St-Jacques Est Princeville Quebec Canada DL546763 20 SC128 03/04/2020 05/04/2020
2132
1005 Mrs Iola Tovar St-Jacques Est Princeville Quebec Canada DL546763 20 HEL122 03/04/2020 05/04/2020
2132
1005 Mrs Iola Tovar St-Jacques Est Princeville Quebec Canada DL546763 20 GLV675 03/04/2020 05/04/2020

Practice
You have split the Booking_Purchases_TBL into two tables. Equipment_TBL lists the
equipment for rent:
Equipment_TBL
Product ID Product Description Daily Rate Purchase Fee
SW111 Segway Segway Pro $49.99 $0.00
SW334 Segway Segway i2 SE $45.99 $0.00
SC009 e-Scooter Razor E90 $20.99 $0.00
SW097 Segway Segway Pro $49.00 $0.00
SC128 e-Scooter Razor E90 $20.99 $0.00
SW765 Segway Navboard LME-S1 $35.99 $0.00
HEL122 Helmet Small $4.99 $24.00
GLV675 Gloves Med $1.99 $5.99
SJ234 Safety Jacket Med $4.99 $20.99

You will now have a total of three tables in your database.


Think carefully
➤ Make a list of the attributes / field headings each table will contain. about what field must
➤ Select a suitable name for each of the new tables. (Hint: do not be included in both
include capital letters or spaces; instead of a space, use an tables to create the
underscore ‘_’.) links shown.

163

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 163 27/04/20 2:37 PM


International Computing for Lower Secondary

➤ Copy and complete the diagram below, filling in the fields for each table to show how
the three tables will be linked.

Product ID
Description
Colour
Daily Rate

Relational databases – designing and linking tables

Learn

Before data can be added to a relational database, the tables being used to store the
data must first be created.
Database designers will first produce a data dictionary which, among other things, will contain:
➤ details of any entities represented in each table in the database; an entity is an
individual person or thing about which data is stored in a database
➤ attributes associated with each entity; attributes represent the characteristics of each
person or thing stored in the database; field names are used to describe each attribute
➤ data types for each attribute / field name (in other words, text, numbers, dates…)
➤ field lengths (in other words, how long each piece of data can be); for example,
the Customer Number in the previous example has a field length of four (only four
characters are used to store each Customer Number)
➤ validation checks to help reduce the chance of errors occurring when data is entered;
we will look at validation in more detail later in this chapter.
This table shows a data dictionary for our Countries–Continents database on page 159.
Table Attribute Name Data Type Field Length Validation Check Required Notes
country_TBL Country_Name Text 60 Presence check Yes Primary Key field
country_TBL Capital_City Text 60 Presence check Yes
country_TBL Country_Population Integer Range check Yes Must be >0
country_TBL Continent Text 12 Lookup list Yes Africa, Asia, Australia, Europe,
South America, North America
continent_TBL Continent Text 60 Presence check Yes Primary Key field
continent_TBL Continent_Size_(Sq_miles) Integer Range check Yes Must be >0
continent_TBL Continent_Population Integer Range check Yes Must be >0

164

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 164 27/04/20 2:37 PM


Unit 8.6 Relational databases: SegwayThere

You will notice from this table and from the diagram on page 159 that the attribute
‘Continent’ appears in both country_TBL and continent_TBL. It is being used to create a
link between the two tables. Continent is a primary key field in the continent_TBL table.
Since it appears in country_TBL to help create a link between the two tables it is known
as a foreign key in country_TBL.
Database applications use relationships to link tables together.

KEYWORDS
data dictionary: a document used to describe the main parts of a database
and how each of the main database parts are linked
entity: an individual person or thing about which data is stored in a database
attribute: represents a characteristic of a person or thing stored in the
database, described using a field name
foreign key: a field in one table which appears in another table, creating a link
between the two tables
relationship: the link between two tables in a database application, created
using a field that appears in both tables

There are three types of relationships in database design:


➤ one-to-one
➤ one-to-many
➤ many-to-many.
Database designers use a special diagram called an entity relationship diagram (ERD),
to show how each of the entities in the relational database are linked.

one-to-one
(Principal) (School)
For example,
one school has
one principal.

one-to-many
(School) (Students)
For example,
one school can
have many
many-to-many students.
(Students) (Course)
KEYWORD
entity relationship
For example, a diagram (ERD):
student can take a diagram used
many courses, and a to illustrate the
course can be taken relationship between
by many students. two entities in a
relational database

165

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 165 03/05/20 1:41 PM


International Computing for Lower Secondary

Think carefully
Practice about how you can control
the number of characters being
Using the list of fields and tables you produced in the entered into a field, how you
practice task on page 163–4: can make sure data within certain
values can be entered into a field or
➤ create a similar data dictionary for each of the three
how you can use input
tables you will use in your ‘SegwayThere’ database masks to control the format
➤ think carefully about the field headings you will use for of data entered into
the attributes in each table; try to select field headings which a field.
are easy to remember but that still describe the attributes
they represent Remember it
➤ identify the primary key fields and is good practice
One table
foreign key fields in each table. not to include spaces or
will have two foreign
capital letters in your
key fields. It will be
field headings.
used to link the other
two tables.

Abstraction
Think carefully about the relationships that must exist between your
three tables in order to reduce data duplication. Now produce an ER
Think carefully –
diagram to illustrate the links between your three tables.
a customer’s personal
What information should only be stored once to help reduce the details should only exist
chance of errors being made when data is recorded? once, but a customer
might rent more
Look at the data in each of the tables to help you consider how than one product
the tables would be linked. The following points help you with this. at a time.

For example:
Each customer can only exist once There is only one Mrs Iola Tovar
but … but …
each customer can have many bookings. she has rented many items.

Each item can only exist once There is only one physical Razor Ego scooter
but … but …
each item can be rented out many different times. Mrs Iola Tovar has rented it out a number of times.

Discuss your data dictionary and ER diagram with your teacher to


make sure your design is correct before moving on to setting up Think about
your database. what fields you will use
to link your tables. Make
sure they are set to
the same data type in
each table in your data
dictionary.

166

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 166 27/04/20 2:37 PM


Unit 8.6 Relational databases: SegwayThere

Database structures

Learn

Like other computer applications, relational databases receive input data, store and
process it, before producing output for the end user. The diagram below shows how the
linked tables in a relational database interact with the other objects in the database.
Forms for data input (each table Linked tables Used to present data in
will have a data entry form) to store data useful formats
Table 1 Reports

cust_ID
title

Table 2

Queries
age

Table 3

INPUT STORAGE AND PROCESSING OUTPUT

Forms:
➤ Used to input data by users of the database.
➤ Data is transferred from the form to the correct table in the database. You should have
Queries already used simple
queries to search for
➤ Used to search for data. data. In this unit we will
➤ Can be used to search for and display data from more than one look at more complex
table at a time. queries.
➤ Can be used to perform calculations.
Reports
➤ Used to display data in a useful format onscreen and as a printout.

167

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 167 27/04/20 2:37 PM


International Computing for Lower Secondary

Populating databases

Learn
KEYWORD
populating a
We know from our previous work with databases, and from what database: the process
we have studied in this unit so far, that databases use tables to of adding new data
store data. to a database or
integrating existing
Adding data to a database table is known as populating the data into a database
database. This can be done in a number of ways.
➤ Create an empty database structure. The user can then add
data to the tables as required; for example, each time a new
customer arrives, or a new rental or purchase is made.
➤ Take an existing data table and import it into a new database.

Practice

The manager of SegwayThere has looked at your data dictionary and has restructured his
original tables to meet your new design.
The owner has copied the data into three Microsoft Excel files so you can import the data
into the new relational database.
Your teacher will give you a copy of three Microsoft Excel files called customer_TBL,
booking_TBL and product_TBL.
Your first task is to:
➤ import each of these files into a blank database and select appropriate data types
(text, integers, dates, and so on)
➤ open a new blank database using Microsoft Access by clicking on Blank desktop
database

➤ give the database an appropriate name; for example, SegwayThereDB and click
Create.
First we will import the data for customer_TBL.
➤ Click on the External Data tab and then the Excel icon to Import data from a Microsoft
Excel file.

168

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 168 27/04/20 2:37 PM


Unit 8.6 Relational databases: SegwayThere

➤ Browse to the file called customer_TBL provided by your teacher.


➤ Select Import the source data into a new table in the current database.
➤ Click OK.

➤ On the Import Spreadsheet Wizard, place a tick in the check box which says First Row
Contains Column Headings, then click Next.

It is good
practice to not
include spaces
➤ Now click on the Customer Number column and select an in field names
appropriate data type and amend the column heading if Use _ instead of
appropriate. spaces.
You should edit
field names
so they now
match your data
dictionary field
headings

Select an
appropriate data
type for the field.

169

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 169 27/04/20 2:37 PM


International Computing for Lower Secondary

➤ Click on each column in turn and repeat this process for every field in customer_TBL.
➤ When all fields from customer_TBL have been correctly set up, click Next.
You will now be able to select a primary key field for your
database table.
Microsoft Access will automatically try to create a primary key
field for you. Be sure to set cust_ID as your primary key field
as shown below.

Remember to
select currency format
for daily fee and
purchase fee.

➤ Click Next and enter the name customer_TBL for your


database table.
➤ Save customer_TBL. Look carefully
Repeat the above process to import data from product_TBL. at the data in this
table. Why would Product
Now import the data from the file called booking_TBL. ID be the most suitable
primary key field?
➤ Edit the field names and data types of the first two fields in the
table to match customer_TBL and product_TBL.

➤ Once you are happy with the field names and data types, click Next.

170

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 170 27/04/20 2:37 PM


Unit 8.6 Relational databases: SegwayThere

Click on ‘Let Access add primary key for this table’. The first field heading in this table
is Customer Number. The same customer number has been entered many times so this
would not provide a unique identifier for each booking.

When you have completed the import process view the table in design view and rename
the primary key in this table to Booking_ID.

Open each table


in turn and adjust the
size for each field to an
appropriate length; for example,
at the moment the longest title
recorded in our customer_TBL
is ‘Miss’ so we could
change that Field Size from
255 to 4.

171

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 171 27/04/20 2:37 PM


International Computing for Lower Secondary

Accurate data entry

Learn
KEYWORD
lookup list: make use
You should already be familiar with the concept of data of a drop-down list of
validation and how important it is. It can help to make sure that values (the user can
the data entered into an electronic database is both reliable and select the value from
accurate. Database developers use validation combined with a a list onscreen – no
range of other controls such as lookup lists and input masks to typing is required) to
enter data into a field;
help with data reliability.
the user selects the
Input masks can be used to make sure data entered contains value from a drop-
capitals, letters and numbers in the right place. The table down list
below shows some of the common input mask controls used in
Microsoft Access.

0 0 to 9 can be entered. A value must be entered in this location


9 0 to 9 or SPACE can be entered. A value does NOT need to be entered in this
location
L A–Z can be entered. A value must be entered in this location
? A–Z can be entered. A value does NOT need to be entered in this location
A A–Z or 0–9 can be entered. A value must be entered in this location
a A–Z or 0–9 can be entered. A value does NOT need to be entered in this location
& Any character or space can be entered. A value must be entered in this location
C Any character or space can be entered. A value does NOT need to be entered
in this location
> All characters following this symbol will be displayed as upper case
< All characters following this symbol will be displayed as lower case

Practice

Your next task is to apply appropriate


validation to the tables.
➤ Open customer_TBL in design view.
➤ Create a lookup list for the attribute
Title (your list should contain Mr,
Miss, Ms, Mx, Mrs – you can add
other appropriate titles if you wish).
• Select Lookup Wizard.
• Select ‘I will type the values that
I want’ and click Next.
• Enter the values you wish to
appear in your lookup list.

172

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 172 27/04/20 2:37 PM


Unit 8.6 Relational databases: SegwayThere

KEYWORD
unit testing: the
process of testing
individual parts or
components in a
computer based
solution

• Click Next and then Next again.


• Click Finish to set up your lookup list.
• View the table again in Datasheet
View and test your lookup list by
clicking on the title field for one of
the existing records. A lookup list
should appear as shown.
➤ Surname and Firstname fields should
be no longer than 30 characters long. In Design View, Add the
add an appropriate validation rule using the LEN following to the
function to these fields. Also, add validation text for Validation Rule to
both Surname and
both fields.
Firstname: e.g.
➤ Use the LEN function to add a length check to the
Len([Username]).
Title attribute (it should be>0).
➤ Customers cannot rent equipment from the company
This is
unless they are 18 years old or above. Add an appropriate validation
an example of
check and text to the Age attribute. unit testing, where we are
➤ Using the input mask controls we looked at earlier, for the input testing each table as a standalone
mask for Title would be: >L<L??. Add this input mask to the Title unit / object in the database to
field in your customer_TBL. make sure it works correctly on its
➤ Save your database by selecting File and then Save. (When own. Only after we are sure each
you save a database file in Microsoft Access, it automatically table works will we begin
saves all parts of your project; you do not have to save each table to test the full
individually.) database.

Use a similar test plan layout to the one shown below to test your Title input masks

Does Expected
Outcome match
Expected Actual Actual Outcome?
Test Reason for test Value Outcome Outcome (Y/N)
1 Invalid title 98W Error message
2 No Data Entered leave Title blank Error message
3 Valid Title entered Mr Accepted
4

173

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 173 03/05/20 8:36 PM


International Computing for Lower Secondary

Pattern recognition Abstraction and generalisation

✪ Identify the pattern used Open the other two tables in turn.
when recording ID number. ✪ Discuss with a friend where and how you could
Once you have recognised apply any validation methods and input masks
the pattern create an input to the fields created in each table.
mask for this field.
✪ Add any validation checks
✪ Design and create Remember you will
and/or input masks you need to look for patterns in
appropriate validation have discussed the data first of all before deciding
checks and/or input masks with your friend to on the input mask format. Not all
for the remaining text fields each table in turn. fields will need an input mask.
in your customer_TBL.
✪ Create a test plan
✪ Test all of your validation similar to the one used with
checks and input masks customer_TBL to ensure all of your
in customer_TBL using a validation checks and/or input masks operate
similar test plan layout to correctly.
the one you used for the
✪ Save all of your work.
Title field.

Linking tables

Practice

Now that the tables have been designed, created and


tested as individual objects, it is time to create and test the
relationships between the tables.
➤ Open the file SegwayThereDB.
➤ Click on the Database Tools tab and click on the
Relationships icon.
➤ The Show Table dialog box will appear. Select on each
table in turn and click Add.
➤ Organise your display in the relationships window so
your tables appear as shown. Notice that the primary/
key fields are labelled with a key icon.

174

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 174 27/04/20 2:37 PM


Unit 8.6 Relational databases: SegwayThere

➤ Click on cust_ID (the primary key) for customer_TBL.


➤ Drag this field over to cust_ID on booking_TBL.
➤ We wish to cascade delete records in all tables and enforce referential integrity. Place
a tick beside Enforce Referential Integrity and Cascade Delete Related Records.

Ensures that a booking cannot be made for


a customer if that customer does not exist in
customer_TBL.

➤ Create a similar relationship between Ensures that if a customer is deleted from


booking_TBL and product_TBL using customer_TBL all of their related records in
product_ID. booking_TBL will also be removed.

➤ Notice that the relationships between the fields in different tables are denoted with
link lines shown in the Relationships window.
➤ Save your file.

KEYWORDS
cascade delete: a feature of relational databases which means that, for
example, if a customer is deleted from the customer table, all of the bookings
linked to that customer will also be removed from the booking table
referential integrity: a feature of relational databases which means for
example that a booking cannot be added for a customer who does not exist in
the customer table

Practice

➤ Open SegwayThereDB.
➤ Double click on booking_TBL to open the table in Datasheet View.

175

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 175 27/04/20 2:37 PM


International Computing for Lower Secondary

➤ Try to enter a booking for a customer. Click on


1007, Miss Dancia McLeod, 817 Rose Lane, West End, the (New) row
London, UK, driving licence number DL991276, aged 27 at the bottom
➤ She would like to book a Segway Pro (Product ID) SW097 of the table to
add a new record.
from 3/5/23 to 5/5/23.
➤ Discuss with a partner the message you received when you
tried to enter this booking.
➤ Discuss the steps you need to take to correct this problem and Check
customer_TBL to
then add the booking to the database.
see if customer 1007
exists in the
database.

Generalisation
Try adding a
booking for cust_ID
With your partner use the knowledge you have developed to 1003 but with a product
create a similar test to check your relationship between booking_ that is not listed in
TBL and product_TBL. product_TBL.

Creating input forms


Learn

Databases provide users with forms to enter data, modify a record or to view a single
record on screen.
Data entered into a form will automatically be added to the correct table in the relational
database.

Practice

➤ Open the file SegwayThereDB.


➤ Highlight customer_TBL in the
Objects panel at the left hand side
of the screen.
➤ Click on the Create tab and then
Form Wizard.

176

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 176 27/04/20 2:37 PM


Unit 8.6 Relational databases: SegwayThere

➤ Click the double chevron icon to move all Available Fields across to Selected Fields

double chevron icon

➤ Click Next and select Column layout, before clicking Next again.
➤ Give the form an appropriate name, such as customer_FRM and then click Finish.
The form will display with the first customer record from customer_TBL.

Generalisation and evaluation

Use the form wizard to create a similar form for booking_TBL, called booking_FRM.
Do not worry about creating a form for product_TBL just yet.
With a partner, discuss the design and layout of the forms you have created. Does it look like
In your discussion, you should consider: a form that could
be printed out
and shown to a
Does the form look professional?
customer?
Do the field headings easily describe the attributes being recorded?
How can you improve the forms? A more relevant
form title would
Would special instructions help the user complete any attribute?
help describe the
How might colour improve the presentation of the form? form’s use.
Is the text large enough on screen?

Data must be entered


in a specific format,
KEYWORD the form could include
an example to help
wizard: a software tool which takes users step-by-step through the
the user
completion of a task

177

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 177 27/04/20 2:38 PM


International Computing for Lower Secondary

Input form design and layout

Learn

Most databases will have more than one form. Database designers try to keep
the database looking professional. They can do this by making sure forms:
Good use of
➤ are consistent; for example, all the same colour, use the same font, have validation rules and
form titles in the same place validation text when
➤ use field headings which clearly describe each attribute being recorded creating the tables
➤ include instructions to help the user; for example, if data is being can help with this.
recorded, they may give an example of the layout such as dd/mm/yyyy
➤ provide easy-to-understand feedback to users.

Practice

Using the feedback from your discussions with your partner, improve the presentation of
customer_FRM and booking_FRM to make it more professional.
➤ Open each form in Design View.

➤ Click on the text in the


You can click on any
form header ‘customer_TBL’
object, such as a text box, on
and edit this to read a Microsoft Access form and edit
‘Customer Details Form’. the properties. The properties
Use the text formatting window is often displayed at the right
tools to amend the size, hand side of the database window.
font and colour of this title If it is not displayed automatically,
to a design of your choice. right click on the object and select
Properties from the menu
➤ Click on each attribute displayed on screen.
label and edit the label to
make it more user friendly;
for example, instead of
cust_ID the first attribute
label could read Customer
Number.

KEYWORD
user friendly: something For example,
that is not difficult to editing text format
learn or understand using the properties
window.

178

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 178 27/04/20 2:38 PM


Unit 8.6 Relational databases: SegwayThere

➤ Edit the font, size and style of each of the attribute labels so they are more user friendly.
➤ Right click on any part of the form to edit the background colour.

You can
also right click on
any text box or label
in the form to edit
background.

➤ In design view, you can move text boxes and labels around to make the form more
user friendly. For example, you may wish to display title, firstname and surname in one
line as that is the way someone would normally write their name.
➤ Click on the surname text field and label and drag it to another position on customer_
FRM.
➤ You will notice that they both move at
the same time.
➤ Separate the label and the text field by
right clicking on the label and selecting
Edit – Cut.
➤ Select Edit and then Paste to add the
label back onto customer_FRM.
➤ You can now move both parts around
separately.
➤ Edit the layout of
customer_FRM so it The grid lines shown in
looks similar to the one design view act as good markers
when moving objects around.
shown, right.
You can also view your form in
➤ Edit your booking_FRM layout view and move the
so it has a similar layout. fields and labels around so you
can see what the final form
looks like after each change
you make.

179

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 179 27/04/20 2:38 PM


International Computing for Lower Secondary

Abstraction
Often the way a database is presented to the user is not the way it is stored or organised.
In this example, SegwayThereDB has three tables but the owner of SegwayThere would like
to be able to see each customer’s details and all of their booking details at the same time.
This level of abstraction can be achieved in a relational database by using a data entry
form which can combine data from more than one source.
✪ The owner of SegwayThere would like a single form which allows them to add customers
and bookings at the same time.
This field
o Click on the Create tab again and select Form Wizard.
will already
o Select and add the fields from customer_TBL as before. be on the
o Select and add all fields from booking_TBL (do not add customer_ID). form.
✪ Before completing all of the steps on the Form Wizard and clicking Finish, with a friend
think what this form might look like and how it might operate.
o Test the form by adding the details of someone you know as a customer.
o Add two bookings for this person.
o Close the form and open customer_TBL to check their details were added
correctly.
o Open booking_TBL to check the two bookings were also added correctly.

QBE v SQL

Learn

Most relational databases use Structured Query Language (SQL) to access the data
stored in the data tables.
Previously, you may have used a method called Query by Example
(QBE) to extract data from a database. A QBE interface provides
Remember: clicking the
the user with a grid. The user adds the fields and search criteria double chevrons allows you to
and the software creates the SQL to actually process the add all fields. If all fields are
query. not needed click on each field
To create a simple QBE to search for the details of all of the in turn and click the single
chevron to move the fields
Segways in product_TBL:
over one at a time.
➤ click on the Create Tab and select Query Wizard
➤ select Simple query Wizard and click OK
➤ add all fields from product_TBL into the selected fields panel
Remember:
➤ click Next to give the query a name, segwayQRY the exclamation
➤ select Modify the query design mark is used to
➤ under criteria for product_type, enter Segway, and run the query. run queries.

180

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 180 27/04/20 2:38 PM


Unit 8.6 Relational databases: SegwayThere

In Microsoft Access you can view the SQL behind any queries.
➤ Double click on segwayQRY.
➤ Click on the Home tab and then View and select SQL view.

The above example shows that SQL statements have three main parts:
➤ SELECT – used to specify the data/fields to be displayed in the query.
➤ FROM – used to identify the source or table the data is to be selected from.
➤ WHERE – used to identify the criteria used to select the data.

KEYWORDS
Structured Query Language (SQL): a specialised language used with
relational databases to input or retrieve data
Query By Example (QBE): an interface that allows users to add fields and
criteria to a grid and then the software creates the SQL needed to process
the data

Pattern recognition and algorithmic thinking


With a friend try to analyse the SQL statement created. product_TBL is
✪ Rewrite the statement in a pseudocode format to make it more identified on the
FROM line; remove it
efficient and easier to understand.
from the SELECT and
✪ Edit the statement in SQL view to remove the WHERE line.
product image from the query results. Delete “,
✪ Run the query to check the how results are product_TBL.
now displayed. [product_image]”
from the SQL.

181

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 181 27/04/20 2:38 PM


International Computing for Lower Secondary

Practice

Microsoft Access can also be used to create your own SQL


queries.
Create an SQL query, using booking_TBL, to search for the details
of all of the bookings made by customer 1005. The query should
display product_ID, date_out and date_back only.
➤ Click Create and then Query Design.
➤ Close the Show Table dialogue box that appears on screen.
➤ Click View and then select SQL view.

➤ Copy and complete the following SQL statement for Notice that cust_ID
this query and then run the query to test that it works is not included in the
correctly SELECT part of the
SELECT [product_ID], [ ], [ ] statement as we do
FROM not want to display it
in the results.
WHERE (([cust_ID])= );

Think carefully
about the data type
used to store cust_ID;
if it is a numeric
value it does not
need “”.

182

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 182 29/04/20 9:10 PM


Unit 8.6 Relational databases: SegwayThere

➤ Test your Query by clicking on the Run icon. The following


results should be displayed.

➤ Close the query results. You will be asked do you want to save
the changes to the design of your query. Click Yes and name
your query 1005Bookings.
Use the example completed above to help you create your own
SQL statement to SELECT and display the product_ID, product,
description and daily_rate FROM product_TBL all products with Think about
a daily_rate of <$25.00. replacing ‘=’ in the
Examine the following SQL statements with a friend and predict WHERE line with the
the outcome of running each statement. ‘<’ symbol to help
with this task
SELECT product_ID, product, description, daily_rate
FROM product_TBL
WHERE product=”e-Scooter”;
SQL statements do
not need a criterion. By
SELECT product_ID, date_out, date_back
leaving out the WHERE
FROM booking_TBL line, the query will
WHERE product_ID=HEL122; display all of the fields
listed in the SELECT
➤ Create an SQL statement using each of the examples shown
statement.
above.
➤ Run each query and check if your predictions were correct.
➤ Try running one of the queries without including the WHERE
statement to see how this alters the results displayed.
The following SQL queries have been created but are not
returning the expected results. Discuss each query with a friend
and try to identify any errors.
SELECT product_ID, product, description, daily_rate
FROM customer_TBL
WHERE product_ID=”SC-009”;

SELECT cust_ID, secondname, firstname, country


FROM customer_TBL
WHERE country =”USA”

183

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 183 27/04/20 2:38 PM


International Computing for Lower Secondary

Go further

Inserting images Remember, these images


belong to someone else and you
The owner of SegwayThere would like to use the database can’t use someone else’s material
to produce a report which contains images of all of the without their permission. You
equipment available for rental. must always give attribution
Before they can do this they have asked you to help them (credit) to the original owners or
creators of a digital artefact if you
source some images to help show what each product looks
are using it in a document you
like.
have created.
◆ Use an advanced internet search to locate appropriate
images of Segways and e-Scooters, and each of the
other products referred to in your database.
◆ Open your file called SegwayThereDB.
◆ Keep a note of the websites you used as sources If you have
for each of your images. permission from others
◆ Open product_TBL in Design View and add a in your class you could add a new
field to the customer_TBL called
new field called product_image.
customer_image and include
◆ Set the data type to Object Linking and
photographs of other students
Embedding Object (OLE Object). and use them to represent the
customers in your database.
However you must have
permission from
each student.

OLE Object data types


are used in Microsoft
Access to allow you to
attach other files to your
database, in this case we
will attach images.

KEYWORD
Object Linking and
Embedding Object (OLE
◆ Use the Form Wizard to create a form for product_TBL. Object): used to allow
◆ Save the form as product_FRM. the linking of existing
files to other programs
◆ Edit the form in Design and Layout view so it has the same
and applications
professional look as the other forms in your application.

184

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 184 27/04/20 2:38 PM


Unit 8.6 Relational databases: SegwayThere

◆ Open the form in data view and right click on the OLE place holder. Select insert and
browse to the location where your have stored your image for that product.

Place holder for OLE content.

◆ Click on the Next Record button at the bottom of the data entry form to move on to
the next product.

◆ Repeat the process until you have added an OLE image for each product in the database.
◆ Save your work.
◆ Finally, do not forget, the owner would like you to create a report which shows all of
the products available for rental. The report should include:
o images of each product
o names of each product underneath the image
o a text box at the bottom of the report listing the sources of the images.

Challenge yourself
More advanced SQL
The SQL statements created earlier in this chapter allowed us to search for and display
data from one table, using specific data.
SQL statements can also be created to allow the user to:
➤ enter their own criteria to search a database
➤ display data from more than one table.
Use what you have learned about SQL to create a new SQL query that will display
the following from customer_TBL.
➤ Create a new query and display the query in SQL view.
➤ Enter the SQL statement shown below to first of all display the cust_ID, surname,
firstname and country of all customers from USA.

185

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 185 27/04/20 2:38 PM


International Computing for Lower Secondary

SELECT cust_ID, surname, firstname, country KEYWORD


FROM customer_TBL parameter query: a query
WHERE country=”USA”; which asks the user to
enter search criteria
➤ Save and test your query to ensure it works correctly.
SegwayThere has customers from many different countries. It would be
A query
better if they have one query that allows the user to enter the country for
which asks the
themselves. Instead of giving exact criteria in the WHERE statement we
user to enter the data
can use [ ] to ask the user to enter the search criteria. in this way is known as
➤ Edit the WHERE statement to read WHERE country = [Enter Country];. a parameter query.
➤ Save and run the query to see how this changes how the query now
works.
The owners of SegwayThere would like to display any bookings shown in
booking_TBL that have been made by customer 1001. But they would like
the firstname and surname of the customer to be displayed also.
cust_ID is the primary
This will involve selecting data from two tables, customer_TBL and key field in customer_TBL
booking_TBL. but also appears in
booking_TBL and a
To select data from two tables it is important that the two tables relationship has been
are already linked. In this example, booking_TBL and customer_ created between the two
TBL are already linked using cust_ID. tables using this field.
➤ Create a new query and display the query in SQL view.
➤ Enter the following SQL statement.
Notice how in this query you
SELECT booking_TBL.booking_ID, booking_TBL.cust_ID, booking_ need to specify the table
TBL.product_ID, booking_TBL.date_out, booking_TBL.date_back, each field is being taken from.
customer_TBL.firstname, customer_TBL.secondname
You can do this by typing
FROM customer_TBL, booking_TBL the table name before each
WHERE customer_TBL=”1001” field in the select line.

➤ Run your query and with a friend examine the results displayed. The results displayed
at first are not correct.

The query is
displaying the first
and second name of
cust_ID 1001 to every
booking contained in
booking_TBL.

186

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 186 29/04/20 9:11 PM


Unit 8.6 Relational databases: SegwayThere

➤ Remember that cust_ID appears in both customer_TBL and booking_TBL. The SQL
statement must include an instruction to also search booking_TBL for cust_ID 1001
➤ Edit the WHERE statement to now read WHERE customer_TBL.cust_ID=1001 AND
booking_TBL.cust_ID=1001;
➤ Run and test the query again to ensure the correct results are displayed this time.
➤ Save the query as bookingnamesQRY.
Create your own SELECT statement to now display the contents of booking_TBL, this
time with the product and description fields included from product_TBL. Use product_ID
SC128 as your search criteria.

Final project
The owners of SegwayThere have decided to start giving lessons in using Segways and
e-Scooters to under 18s. They have recorded some details of students and lessons in a
new database called lessons_DB. Your teacher will give you a copy of this file.
➤ Open the file called lessons_DB.
➤ Produce a data dictionary which can be used to describe the contents of both tables
in the database. Include details of primary keys, validation rules and input masks you
will apply to each field.
➤ Some comments have been included in the description column for some fields to
help you with this task.
➤ Apply the validation rules and input masks you have designed to each of the tables in
the database.
➤ Produce a test plan and test the validation rules in each table.
➤ Produce an entity relationship diagram to show how the two tables are related.
➤ Create a one to many relationship between student_TBL and lessons_TBL.
➤ The owner would like each student to have a card with their name and You can
photograph on it so the tutor can easily remember their name. search for images
from the
● Add a new field called student_picture to student_TBL. Set this field as
internet.
an OLE object. Add a picture to student_TBL for each student.
● Produce a report called student_card_RPT which can be used to
print a student’s full name and their photograph. Remember to
create a parameter
➤ The owner would also like to have one form which allows them
query first which
to enter data into student_TBL and lesson_TBL at the same asks the user to
time. Create a form which is appropriate for this task. enter student_ID.
➤ With a friend evaluate your form layout to determine how
professional it is. You should discuss:
● text style, size, font and colour used
Use the form wizard to
● use of background colours
add details from both
● how well the field headings describe each attribute tables, one after the
● use of special instructions to help the user. other. Remember that
➤ Create an SQL statement that allows the user to search for student_ID need only
and display all of the data on all lessons on the 28 April 2020. be included once.

187

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 187 27/04/20 2:38 PM


International Computing for Lower Secondary

➤ The results of this query should be displayed in a report called lessonRPT. Results
should be grouped by vehicle type and sorted by lesson_time.
➤ Create an SQL statement that displays the student firstname and surname from
student_TBL along with details of the lessons recorded in lesson_TBL. The query
should use student_ID as the search criteria.
➤ Display the results of this query in a report called lesson_namesRPT.

Evaluation
➤ Ask a friend to test your database solution against each of the following
requirements which say that the database should contain:
o easy to use interface with links to all forms, queries and reports.
o A single data entry form to enter data into both tables at the same time.
o Queries and reports to:
• allow user to print a list of lessons each day (grouped by vehicle type and
sorted by time)
• print a bill for the user.
➤ Ask your friend to evaluate your form and report layouts to determine how
professional they are. You should discuss:
o text style, size, font and colour used
o use of background colours
o how well the field headings describe each attribute
o use of special instructions to help the user.
➤ Write down any improvements your friend recommended and then describe in a
short written report any changes you made to your database and why.

188

481992_U6_Int_Com_Low_Sec_SB_158-188.indd 188 27/04/20 2:38 PM


Glossary
Key Term Definition
absolute cell reference a cell reference that remains big data the large volume of data that is created by
constant even if it is copied to other cells digital devices and websites every day; it is analysed
accessibility providing support for the individual needs using computer programs
of all users, for example by including audio output of binary a number system which uses combinations of
content for users with visual difficulties two digits (0 and 1) to represent all other values. Used
American Standard Code for Information to represent data in computer systems
Interchange (ASCII) a standard code used to binary digit 0 or 1, the smallest unit of data
represent text on computers and other electronic represented by a computer
devices binary number format numbers represented using
analogue a continually varying signal, for example a 1s and 0s
sound signal bit short for binary digit
analogue to digital converter (ADC) used to convert bit depth the number of bits used to store a single
analogue signals, such as the human voice, to digital sound sample
signals
built-in functions (Microsoft Excel) functions that
arguments values that are passed to the function exist within the software for use by the user
in the brackets that follow the function name; these
built-in functions (Python) functions that can be used
values are used within the function
in the Python language without adding any additional
arithmetic operators +, – , *, / and other symbols which code
can be used for arithmetic
byte a group of 8 bits, often used to represent a single
arithmetic shift a process of shifting binary digits left character in a computer
or right to help perform complex calculations
cascade delete a feature of relational databases which
artificial intelligence (AI) the study of machines and means that, for example, if a customer is deleted from
application of algorithms designed to carry out tasks the customer table, all of the bookings linked to that
in a way which mimics the thought processes normally customer will also be removed from the booking table
associated with human beings
case-sensitive can distinguish between capital and
assignment statements a statement which assigns a small letters
variable a value; for example, x = 3
cell single square or rectangle in a table used to contain
attribute (database) represents a characteristic of a an item of data or a table header
person or thing stored in the database, described using
character set the set of characters that can be
a field name
represented on any device
attribute (web page) used to define how the text,
chatbot a computer program designed to mimic a
images and other content is to be displayed on a
human conversation
web page, normally added to the opening tag of an
element; for example, <p align = ‘left’>This is left class attribute an attribute which can be used to
aligned</p> define styles for other elements with the same name so
they all have the same style
backup the process of making a copy of a program
or file. This allows the developer to restore work if the cloud storage online storage space for files and
original file becomes damaged in some way documents
base 10 another term for decimal as it is based on column index num the column number of the data
10 digits that will be returned if there is a match for the lookup
value in the table array
base 16 another name for hexadecimal because it is
based on 16 characters

189

481992_GLO_Int_Com_Low_Sec_SB_189-194.indd 189 27/04/20 2:46 PM


International Computing for Lower Secondary

comments (HTML) text used to explain your code; they data types the different ways in which data can be
can be seen by anyone viewing the HTML code but are stored; for example, number, string, date
not displayed in the browser window data validation the process of checking data entered
comments (Python) text entered by the programmer to ensure that it is acceptable
to improve the readability of the code; they start with decimal number system number system using the
the # symbol in Python digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
communications protocol an agreed standard or set of dedent move the Python code out by four spaces
rules for sending or receiving data on a network
digital footprint the digital data held about a person
condition an expression which evaluates to true or as a result of their online activity
false; for example, X<10?
distributed denial of service (DDoS) a malicious
conditional formatting applying formatting such as attack on a network that can prevent users from
colour to a cell based on certain criteria logging on to access their data
copper cable has a core of copper wires which is div tag a tag <div> </div> used to group sections of
covered in plastic or rubber; the wires can be twisted HTML elements together for further formatting; for
together; data transmission is through the use of example, using CSS
electrical signals; copper cable is cheaper than fibre
domain hosting service a service where users can
optic cabling but the speed of data transmission is
upload their own website and make it available on the
much slower
internet
cost price the price at which a product is bought by the
domain name the address of the server which holds
owner of the store
the email
counter variable a variable which is used to count the
ELIF a statement which is part of an IF statement but
number of times a loop has been executed; it is usually
provides an alternative pathway. There can be multiple
increased by 1 each time the loop is executed
ELIF statements in one IF statement
CSS (Cascading Stylesheets) the language used
emoji a graphic which is a visual representation of an
to describe how content on a web page should be
emotion
displayed in the browser window
empathy the ability to understand the feelings of
CSS property the attribute you want to change
another person
using CSS
encrypted data encoded in some way to protect it
CSS style rules the actual rules used to define how
items described using HTML will be displayed in the encryption a process which scrambles data so that it
browser window cannot be read by unauthorised users
CSS value the new value you wish to assign to the encryption key the key which will decode the data so
property identified in a CSS style tag that it can be read by a receiving computer
cyber crime a malicious attack on a computer system entity an individual person or thing about which data is
stored in a database
cyber security the different ways in which we protect
networks, programs and data from attack and entity relationship diagram (ERD) a diagram used
unauthorised access to illustrate the relationship between two entities in a
relational database
data dictionary a document used to describe the
main parts of a database and how each of the main error alert a user defined message that will appear
database parts are linked when the user enters data that breaks the validation rule
data integrity the correctness and accuracy of data in execute another word for running a program
a database external CSS a separate document is written
data modelling using mathematical functions and containing the CSS for a website. Each page in the
calculations on data to predict or model what may website contains a link to that file inside the <head>
happen in the event of certain changes </head> tags at the start of an HTML document
data redundancy the unnecessary repetition of data in fibre optic cable a cable with a glass or Perspex core
a database used to link networks together; data transmission is via
light signals and the speed of data transmission is very
data security protecting data
fast

190

481992_GLO_Int_Com_Low_Sec_SB_189-194.indd 190 27/04/20 2:46 PM


Glossary

field names names used to describe a piece of input a function which Python uses to capture string
information about a single person or thing data from users
file server the main computer on the network; it is input mask a special control used to ensure data is
more powerful than all of the other computers with a entered in a specific format; for example, dates must be
large amount of RAM and hard disk space entered as mm/dd/yyyy
filter a spreadsheet feature which allows the user to input message a user defined message which will
apply certain criteria and exclude or show certain data appear when the user is entering data into a cell
firewall hardware or software which monitors and integer whole number
filters data entering and leaving the network interactive mode the Python shell allows commands to
fixed length having a set number of bits to represent be entered and run immediately
a value; for example, numbers in binary are normally interactive web page a web page containing content
shown using 8 bits the user can engage with, for example through the use
flat-file database a database which stores all data of buttons to make selections, including videos and
items using one table sounds for the user to play, or games for the user to
foreign key a key field in one table which appears in play
another table, creating a link between the two tables internal CSS the style definition would be included as
hackers individuals who try to gain unauthorised access part of the <head> </head> tag at the start of an HTML
to computer systems to damage them or steal data document
hertz a unit of measurement which tells us how many internal style CSS definitions which have been included
sound samples were taken in a single second in the <head> tags of an HTML document
hexadecimal (hex) a number system which uses 16 internet service provider (ISP) a company who
characters 0–9 and A–F; often used by programmers to provides users with an internet connection for a
simplify long strings of binary numbers subscription fee
high bandwidth bandwidth refers to the amount of interpreter the feature of Python which translates
data that can be transferred on a communications line the Python code into language that the computer can
in a given time understand, line by line
homepage the start-up page of a website, the page keylogger a malicious software application which will
that loads first when the website is displayed in a web collect the keystrokes that a person is typing at the
browser computer; typically used to find out peoples’ passwords
HTML elements the opening tag, closing tag and Least Significant Bit (LSB) the digit to the right hand
content to be added to an HTML document; for example, side of the number; the bit with the smallest place
<p>This is a paragraph</p> is an HTML element value
hypertext clickable links on a web page length check a validation check which is used to ensure
that the value entered has a particular number of
Hypertext Markup Language (HTML) the language
characters; for example, a check to ensure that a name
used to create web pages
has at least five characters
IDLE interface Python’s Integrated Development
levels of access limiting the activities different users
and Learning Environment which provides features for
can perform on the computer system, based on their
creating, editing and running programs
role in the organisation
IF statement a statement which evaluates a condition
local area network (LAN) a network spread over a
and places one value in the cell if the condition is true
small geographic area like a building
and another value in the cell if the condition is false
logic error when the program does not do what the
indent move the Python code in by four spaces
programmer wanted it to
initialise setting a variable to a starting value. For
lookup list make use of a drop-down list of values
example, x=0
(the user can select the value from a list onscreen – no
inline CSS CSS which is applied to a single element in typing is required) to enter data into a field; the user
the <body> section of an HTML document selects the value from a drop-down list

191

481992_GLO_Int_Com_Low_Sec_SB_189-194.indd 191 27/04/20 2:46 PM


International Computing for Lower Secondary

lookup statement used to search through a table of pharming redirecting users to bogus websites to
data for a value and then return results if that value is capture personal details
found phishing sending bogus emails to capture personal
lookup value the value used to search through the details
lookup table place value the numerical value a digit has as a result
machine code the language that a computer uses to of its position in a number; for example, the number
carry out instructions 2410 actually represents (2 × 10) + (4 × 1)
macro a small program which is used to automate a podcast a digital audio file that is made available
task on the internet and can be listened to online or
malware software designed to damage a computer downloaded to a computer
system or its data populating a database the process of adding new
meta tags a coding statement that describes some data to a database or integrating existing data into a
of the content on the web page; this can be used by database
search engines to help identify if the page should be presence check a validation check which is used to
returned in a search ensure that there is a value entered. A length check can
metadata data about other data; for example, the be used to do this; for example, a check to ensure that
use of style definitions in an HTML document used to the value entered has at least one character
describe how web page content is to be displayed primary key field a field used to uniquely identify a
microphone an input device used to enter sound into a record in a database
computer print statement a Python statement used to output
Most Significant Bit (MSB) the digit to the left hand text or values onto the screen
side of the number; the bit with the largest place value program code the Python code created in the IDLE
multimedia a mixture of sound, video, animation and text Python shell the Python interactive mode, where
named cell a name given to an individual cell in a commands can be typed directly
spreadsheet query a process of searching for data in a database
named cell range giving one cell or a set of cells a Query By Example (QBE) an interface that allows
name; the cells can be referred to using the name users to add fields and criteria to a grid and then the
assigned software creates the SQL needed to process the data
navigational structure the pathway the user can range check a validation check which is used to ensure
follow when visiting the various web pages on a website that the value entered lies within a given range; for
nested IF statement an IF statement which is example, 1–100
embedded in another IF statement ranking the position in which the company’s website
nibble a 4 bit number sits when a search is done. The higher the ranking the
more popular the website is
nonverbal communication communication made
without speaking such as gestures. referential integrity a feature of relational databases
which means for example that a booking cannot
Object Linking and Embedding Object (OLE Object)
be added for a customer who does not exist in the
used to allow the linking of existing files to other
customer table
programs and applications
relational database a database which stores data
ordered list a list where each item on the list is given a
using two or more linked tables
place value such as ‘1’, ‘a’, ‘A’, ‘i’ or ‘I’
relationship the link between two tables in a database
parameter query a query which asks the user to enter
application, created using a field that appears in both
search criteria
tables
parental controls rules, set by parents, which govern
repetition repeating sections of code in a loop
the websites that are allowed to be viewed on a
computer robot a machine designed to automatically carry out a
pre-programmed task without human intervention
peripherals hardware connected to a network such as
printers and scanners Roman numerals for example, i, ii, iii, iv

192

481992_GLO_Int_Com_Low_Sec_SB_189-194.indd 192 27/04/20 2:46 PM


Glossary

router a piece of networking equipment that shares a style tag used to contain information or rules which
network connection between devices; it can be wired or will define how items described using HTML will be
wireless and allows a LAN to connect to the internet displayed in the browser window
sample rate the number of sound samples taken each suite a section of code which has been indented at the
second same level
satellite link a radio link between one station syntax rules the rules of a programming language
transmitting on Earth and another through a satellite which determine how its instructions are written
script mode Python’s text editor which allows table array the set of data that will be searched using
programmers to enter a list of commands and they are the lookup value
executed together table header data used to describe the contents of
selection selecting statements based on a decision each column in an HTML table
selling price the price at which a product is sold to tables organised collection of related information
customers tags hidden key words in a web page which describe
social influencers individuals who make use of social the content to be displayed in the browser window; for
media and whose opinions and actions can influence example, <p> is an opening tag which is used to describe
other users of social media a paragraph, </p> is the closing tag for the paragraph
social media websites that allow users to create and telecommunications link using technology like fibre
share content or to participate in social networking optic cables, computers are linked to the internet; the
solo adventure game a game in which the player link is the channel that allows communication between
assumes the role of the main character computers and the internet
sort to change the order of data; for example, data can test plan a document containing information about
be sorted in alphabetical order or numerically how the program will be tested and the data used to
test it
sound card a hardware device inside a computer which
can convert analogue sound signals to digital data transistor a tiny switch that can be activated by
electrical signals. If the transistor is ON it represents 1,
spam email that is sent as part of a large set of
when it is OFF it represents 0
messages; the email is not wanted by the receiver
type check a validation check which is used to ensure
special characters symbols and other characters
that the value entered is of a certain data type; for
(aside from standard letters, numbers and punctuation
example, a check to ensure data is numeric
symbols) which can be created using a standard
keyboard, such as #, ~, % unit testing the process of testing individual parts or
components in a computer based solution
spyware software that aims to gather information
about a person or organisation without their unordered list a list of text appearing on a web page
permission. The software is usually downloaded with no special order or sequence
without the user’s knowledge user friendly something that is not difficult to learn or
standalone computers computers which are not understand
connected to a network user identifier the part of the email address which
storyboard a set of line drawings which provide a basic uniquely identifies the user
outline of the content of pages of an application user-defined functions functions defined and created
string data type data which is made up of letters, by the programmer
numbers or any characters on the keyboard validation ensuring that the data entered by the user is
structure diagram a diagrammatic illustration of the acceptable
pathway through the pages of a website variable a named memory location used to store
Structured Query Language (SQL) a specialised data of a given type during the program execution; a
language used with relational databases to input or variable can change value as the program runs
retrieve data variety the number of different types of data
style information information relating to how an item generated
will be presented on an HTML document when it is velocity the speed of data processing
opened in a browser window

193

481992_GLO_Int_Com_Low_Sec_SB_189-194.indd 193 27/04/20 2:46 PM


International Computing for Lower Secondary

Vertical Lookup (VLOOKUP) table a table in a website developers individuals or groups of individuals
spreadsheet which is be used to lookup a value and responsible for the end-to-end coding of websites
return data to a cell in the spreadsheet website filtering software which enables websites to
video conferencing using the internet to transmit be allowed or blocked based on their content
pictures and sound between computers while loop a loop which will continue to run while a
virus a program which gains access to a computer and condition is true
seeks to damage the computer system or collect data wide area network (WAN) a network spread over a
VLOOKUP makes use of a lookup table of data to large geographic area such as a country
match the contents of a cell with a value in the lookup wizard a software tool which takes users step-by-step
table through the completion of a task
Voice over Internet Protocol (VoIP) using the internet worm a malicious software application which spreads
to make telephone calls across computer networks; typically used when an
volume the amount of data generated email attachment is opened and the program is
web browser software which allows the user to view activated
web pages on the world wide web
web browser application a software package used to
view website content

194

481992_GLO_Int_Com_Low_Sec_SB_189-194.indd 194 27/04/20 2:46 PM


Index
chatbots 10
A ChatNow 45
absolute cell references 126, 135–6
class attributes 83–6
accessibility 67
cloud storage 54
analogue signals 31
coding see CSS; HTML; Python
analogue-to-digital converters (ADCs) 31, 48
colour specification, HTML 28–9
AND operator 111
comments
arguments 138, 139
in HTML 74, 75
arithmetic operators 95
in Python 100–1
arithmetic shifts 34–5
communications protocols 52–3
artificial intelligence 8
comparisons 113
ASCII (American Standard Code for Information
Interchange) 15–16 conditional formatting 126, 128–30
assignment statements 95, 105–6, 113 conditions 108, 109, 141
attributes see also IF statements
databases 164, 165 copper cables 52
spreadsheets 149 counter variables 122
website development 80–1, 83–4 COUNTIF function 145
CSS (Cascading Stylesheets) 67, 68
B class attributes 83–6
backups 88 external stylesheets 87–8
bandwidth 46–7, 54 internal style 84
base 10 see decimal number system style tags 76–8, 80–1
base 16 (hexadecimal number system) 8, 26–30 CSS properties 80
big data 49, 126 CSS values 80
binary calculations 24–5, 33–5 cyber crime 59–60
binary conversion spreadsheet 20–1 cyber security 38
binary digits (bits) 14
binary number system 8, 17, 18–19 D
conversion to and from decimal 20–3 databases 158–9
text storage 15–16 conversion of flat-file to relational database
format 162–4
bit depth 32
data validation 172–4
bits 14
designing tables 164–6
Boolean data 102
entity relationship diagrams 165
Boolean operators 111
field names 169–70
built-in functions 138–40
input forms 176–80
bytes 14
inserting images 184–5
C linking tables 165–6, 174–6
cascade delete 175 organisation 161–2
case-sensitivity 97 population of 168–71
cells 74 queries 180–3, 185–7
character sets 15–16

195

481992_IND_Int_Com_Low_Sec_SB_195-200.indd 195 27/04/20 4:41 PM


International Computing for Lower Secondary

database structures 167


data dictionaries 164–5
F
fibre optic cables 51, 52
data integrity 161, 162
field names 160
data modelling 126
file servers 51
data redundancy 161, 162
filtering data 145–6
data security 61–2
firewalls 61
data storage 14, 63–4
fixed length data groups 19
cloud storage 54
flat-file databases 158
numbers 17
conversion to relational database
sound 31–2 format 162–4
text 15–16 foreign keys 165
data transfer speeds 64 forms
data types 95, 102 databases 176–80
OLE Object 184–5 HTML 91–2
data validation formulas 155–6
databases 172–4 functions 132, 138–40
spreadsheets 131–3
decimal number system (base 10) 17 H
conversion to and from binary 20–3 hackers 61
conversion to and from hexadecimal 26–7 hertz (Hz) 31
digital footprint 49 hexadecimal (hex) number system
digital processing systems 11 (base 16) 8, 26–30
distributed denial of service (DDoS) 60 homepages 68
division tags (divs) 79–81 HTML (Hypertext Markup Language) 55, 67
domain hosting services 54 colour specification 28–9
domain names 39 comments 74, 75
CSS style tags 76–8, 80–1
E divs 79–80
elements, HTML 67 forms 91–2
ELIF statements 117–19 hyperlinks 86, 89
ELSE statements 108–10, 117 images 89
email 39–40 lists 72
phishing 60 tables 74–6
subject lines 43 variables 91
tone 43–4 HTML elements 67
voting options 40–2 HTTP (Hypertext Transfer Protocol) 53
emoji 38, 45 HTTPS (Hypertext Transfer Protocol Secure) 53
encryption 61 hypertext 55
entities 164, 165
entity relationship diagrams (ERDs) 165 I
error alerts 131–2 IDLE interface 95, 97
error correction 100, 103, 106, 107 IF statements
errors combining conditions 111–13
logic 116 nested 127, 143–4
overflow 33 Python 108–13, 117
external CSS 87–8 spreadsheets 126–7, 141–5

196

481992_IND_Int_Com_Low_Sec_SB_195-200.indd 196 27/04/20 4:41 PM


Index

images
in databases 184–5
N
named cell ranges 126, 134–5
in HTML 89
natural language 12
indentation 109, 110
navigational structure of websites 69
initialising a variable 105
nested IF statements 127, 143–4
inline CSS 78, 87
network connections 51, 52
input devices 11–13
networks 50–3
input forms
internet 53–4
databases 176–80
nibbles 14, 26
HTML 91–2
nonverbal communication 45, 46
input function, Python 102–5, 121
Notepad++ 73
input masks 160, 161, 172, 173
input messages 131–2 O
input validation 122–3 Object Linking and Embedding Object (OLE Object)
integers (whole numbers) 102 184–5
interactive messaging systems 45 ordered lists 72
interactive webpages 67 OR operator 111
internal CSS 78, 84, 87 output devices 11
internet 53–4 overflow errors 33
web browsers 55–7
Internet Service Providers (ISPs) 53, 54
P
parameter queries 186
interpreters 98
parental controls 55
K peripherals 51
keyloggers 60 pharming 60
phishing 60
L place value 17
Least Significant Bit (LSB) 18–19 podcasts 68
length checks 127, 173 populating a database 168–71
levels of access 62 presence checks 127
lists, HTML 72 primary key fields 159, 161, 170
local area networks (LANs) 38, 51, 52 print statements 97
logical operators 108 programming see Python
logic errors 116 properties windows 178
lookup lists 172 Python 95–8
lookup statements 126, 149–50 assignment statements 105–6
M combining conditions 111–13
machine code 98 comments 100–1
macros 152–4 ELIF statements 117–19
malware 59 error correction 100, 103, 106, 107
MAX function 139 IF statements 108–13, 117
metadata 84 indentation 109, 110
meta tags 55, 56 input function 102–5, 121
microphones 48 input validation 122–3
Most Significant Bit (MSB) 18–19 layout 101
multimedia 45, 46 logic errors 116

197

481992_IND_Int_Com_Low_Sec_SB_195-200.indd 197 27/04/20 4:41 PM


International Computing for Lower Secondary

new programs 99 data validation 131–3


opening programs 100 filtering data 145–6
running programs 99 IF function 141–5
saving programs 99 linking data between worksheets 151–2
Script Mode 99–100 macros 152–4
suites 110 named cell ranges 134–5
syntax rules 114 sorting data 147–8
test plans 116 Vlookup tables 149–50
variables 120 spyware 60
while loops 122–3 standalone computers 51
Python shell 97–8 storyboards 69–70
string data type 102
Q structure diagrams 69
queries 160, 180–3, 185–7
Structured Query Language (SQL) 180–3, 185–7
Query by Example (QBE) 180–1
style see CSS
R style tags 76–8
range checks 127 suites 110
ranking of websites 48 SUM function 138
real numbers 102 syntax rules 114
referential integrity 175
relational databases 158–9
T
table arrays 149, 150
see also databases
tables 160
relationships, databases 165
databases 161–6
repetition 95
HTML 74–6
robots 8–11
tags 67
routers 52, 53–4
telecommunications links 46–7
S test plans 116
safe use of technology 57–8 times tables game 125
sample rate 31 transistors 14
satellite links 52 Transmission Control Protocol/ Internet Protocol
selection 95, 108 (TCP/IP) 53
smart fridges 11 tuples 149
social influencers 49 type checks 127
social media 38, 48–50 U
sorting data 147–8 unit testing 173
sound cards 48 unordered lists 72
sound sampling 31–2, 36 URLs (website addresses) 54
spam 61 user friendly forms 178
special characters 15, 16 user identifiers 39
spreadsheets 126–7
absolute cell references 135–6 V
binary conversion 20–1 validation 95
built-in functions 138–40 validation checks
complex formulas 155–6 databases 161, 172–4
conditional formatting 128–30 Python 122–3

198

481992_IND_Int_Com_Low_Sec_SB_195-200.indd 198 27/04/20 4:41 PM


Index

validation rules, spreadsheets 131–3 website developers 67


variables 91, 102, 120 website development 67–8, 89–94
assignment statements 105–6 planning 69–71
video conferencing 38, 46–7 see also CSS; HTML
viruses 60 website filtering 55
Vlookup (Vertical Lookup) tables 149–50 while loops 122–3
Voice over Internet Protocol (VoIP) 38, 47–8 wide area networks (WANs) 52
voice recognition 12–13, 31, 36 wizards 177
voting options, email 40–1 worms 60

W
web browsers 38, 55–7, 67
website addresses (URLs) 54

199

481992_IND_Int_Com_Low_Sec_SB_195-200.indd 199 27/04/20 4:41 PM

You might also like