International Computing For Lower Secondary Students Book Stage - 8
International Computing For Lower Secondary Students Book Stage - 8
International Computing For Lower Secondary Students Book Stage - 8
STAGE
8
DIGITAL
COMPUTERINFORMATION
DIGITAL INFORMATION
LITERACY
SCIENCE TECHNOLOGY
LITERACY TECHNOLOGY
Introduction 4
Glossary 189
Index 195
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.
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.
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.
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.
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.
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
10
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.
11
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.
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
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
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.)
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
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
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
Decomposition
16
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
Practice
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.
18
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
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
✪ 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
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:
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:
21
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.
22
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 have been 0011011110 queries about bookings for next year.
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
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
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
(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
11012 is 1310 in
decimal; 1310 is D16
in hexadecimal
26
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.
2 = 10
27
2 = 10
28
Practice
29
✪ 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
30
Sample 2 Sample 3
111
110 Analog input
Binary values
Sample 1
31
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
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
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
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
➤ 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.
➤ 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
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?
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
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
Evaluation
37
38
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
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
41
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
42
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.
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.
43
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.
➤ 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?
➤ 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
Learn
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
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.
Learn
46
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?
47
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
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
48
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.
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
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.
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?
50
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.
51
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.
52
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
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
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
➤ 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
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.
57
Here are some of the problems the team and Dr Kecheng have seen:
58
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
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
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
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.
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
◆ 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
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
63
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
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
➤ 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
67
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
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
69
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
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
71
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
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>
73
✪ 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.
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.
74
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
➤ 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.
76
➤ 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.
➤ 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.
77
{
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.
78
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
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
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
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>
Generalisation
81
Algorithmic thinking
82
Learn
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
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
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
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.
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
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.
86
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
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
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
{
88
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
90
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
➤ 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
93
➤ 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
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
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
96
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
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
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
➤ 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
Practice
101
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
102
Practice
➤ 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
➤ 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
Practice
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.
105
Practice
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
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.
107
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.
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
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’
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
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
110
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
Practice
112
Algorithmic thinking
Learn
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’
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
Practice
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.
114
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
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
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
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”
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
Decomposition
Practice
119
Learn
➤ 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
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.
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
122
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.
123
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.
124
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
126
127
Learn
128
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
➤ 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 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
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
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.
132
Practice
133
Learn
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
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
136
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:
137
Decomposition
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
138
Algorithmic thinking
139
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
Learn
The IF function can put one of two values in a cell depending on the outcome of
evaluating a condition.
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
➤ 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
142
Pattern recognition
When you copy a formula to other cells there are similarities
between the formulas in each cell.
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
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.
144
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.
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
➤ Part of the spreadsheet is shown. Note that some of the row numbers are missing;
these rows contain the filtered (hidden) data.
To clear the filters, choose Data Tab » Filter or tick “Select All” in the filtered columns.
146
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.
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
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
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
149
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
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
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
152
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?
➤ 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
➤ 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
Go further
◆ 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.
155
◆ 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
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
158
country_TBL continent_TBL
159
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.
160
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.
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
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
162
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
163
➤ 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
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
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
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
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.
166
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
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
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
➤ 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
➤ 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.
➤ Once you are happy with the field names and data types, click Next.
170
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.
171
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.
Practice
172
KEYWORD
unit testing: the
process of testing
individual parts or
components in a
computer based
solution
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
✪ 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
174
➤ 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
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.
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
176
➤ Click the double chevron icon to move all Available Fields across to Selected Fields
➤ 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.
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?
177
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.
KEYWORD
user friendly: something For example,
that is not difficult to editing text format
learn or understand using the properties
window.
178
➤ 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
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
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
181
Practice
➤ 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
➤ 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”;
183
Go further
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
◆ 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.
◆ 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
➤ 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
➤ 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
➤ 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
189
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
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
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
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
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
195
196
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
198
W
web browsers 38, 55–7, 67
website addresses (URLs) 54
199