You are on page 1of 188

Cambridge IGCSETM

For over 60 years Marshall Cavendish Education has been


empowering educators and students in over 80 countries with
high-quality, research-based, Pre-K-12 educational solutions.

Cambridge
We nurture world-ready global citizens by equipping students
with crucial 21st century skills through our resources for schools
and education centres worldwide, including Cambridge schools,

Computer Science
IGCSE
catering to national and international curricula.

The Marshall Cavendish Education Cambridge IGCSETM Computer Science series


TM
is designed for students studying for the Cambridge IGCSE and IGCSE (9–1)

Computer Science
Computer Science syllabuses (0478/0984). The series focuses on developing
important computer science skills relevant to real-world applications.

SB The Student’s Book:


• Encourages active and inquiry-based learning through hands on activities and discussions
• Supports subject literacy with concise language, language support and bite-sized concepts
• Caters to the international landscape with multicultural photographs, visuals and other references
• Promotes visual learning through concept infographics and clear illustrations
• Includes mind maps and links that build learners’ understanding of the relationships between concepts
• Nurtures life-long learning in building digital literacy skills which students can use beyond their course
• Helps students develop 21st century competencies, so that they become future-ready

STUDENT’S

STUDENT'S BOOK
BOOK
This resource is endorsed by Series architecture
Cambridge Assessment International Education • Student’s Book
✓ Supports the full Cambridge IGCSE and IGCSE • Workbook
(9–1) Computer Science syllabuses (0478/0984) for • Teacher’s Guide
examination from 2023.
• e-book
✓ Has passed Cambridge International’s rigorous
quality-assurance process

✓ Developed by subject experts


✓ For Cambridge schools worldwide Greg Shilton
Megha Goel
ISBN 978-981-4941-59-4

9 789814 941594

C01(S)IGCSECS_SB_Cover.indd All Pages 12/5/21 11:11 AM


Cambridge
IGCSE TM

Computer Science
STUDENT’S
BOOK
Greg Shilton
Megha Goel

SB CS PP.indb 1 14.5.21. 14:13


© 2021 Marshall Cavendish Education Pte Ltd

Published by Marshall Cavendish Education


Times Centre, 1 New Industrial Road, Singapore 536196
Customer Service Hotline: (65) 6213 9688
E-mail: cs@mceducation.com
Website: www.mceducation.com

First published 2021

All rights reserved.

No part of this publication may be reproduced, stored in a retrieval system


or transmitted, in any form or by any means, electronic, mechanical,
photocopying, recording or otherwise, without the prior permission of the
copyright owner. Any requests for permission should be addressed to
the Publisher.

Marshall Cavendish is a registered trademark of Times Publishing Limited.

ISBN 978-981-4941-59-4

Printed in Singapore

Questions and answers have been written by the authors.

Third-party websites and resources referred to in this publication and


videos linked to the Watch feature have not been endorsed by Cambridge
Assessment International Education.

SB CS PP.indb 2 14.5.21. 14:13


The publisher would like to acknowledge the following who have kindly given isolated on white background © WORAWUT PHUKHOKWAY123rf.com; p.52 Close-up
permission for the use of copyright materials. macro view of new SSD Solid state drive fast data transmission disk for personal
computer during upgrade © adrianhancu 123rf.com; p.52 Stacked macro shot of a
Chapter 1 p.1 Futuristic technology concept, Mixed media, Innovations data systems folding red and silver USB pen drive © Mike Caffrey istockphoto.com; p.53 DVD drive
connecting people and robots devices. AI, Artificial Intelligence, Robotic hand on with disc isolated on white background © Igor Purici 123rf.com; p.54 Modern web
blue circuit board background. Innovative technologies and communication, © Pop network and internet telecommunication technology, big data storage and cloud
Nookunrat dreamstime.com; p.2 Two hands on a white background, fingers © Sergii computing computer service business concept: server room interior in datacenter in
Galkin dreamstime.com; p.16 Simple vector illustration. The icon baseball cap, © blue light © scanrail 123rf.com; p.54 Global network mesh. Social communications
Dychek dreamstime.com; p.17 Voice wave isolated on white background. Voice background. Earth map. Vector illustration © maxborovkov 123rf.com; Chapter 4 p.56
visualisation in simple black and white monochrome style. Voice icon, vector, © Router icon © arcady31 123rf.com; p.59 Programming code abstract technology
Seveniwe dreamstime.com; Chapter 2 p.21 Double exposure of businessman use background of software developer and Computer script © Monsit Jangariyawong
smartphone, communication node tower or 4G 5G network telephone cellsite and 123rf.com; p.60 Windows 8.1 on HP Pavilion Ultrabook © Manaemedia dreamstime.
cityscape urban at sunset as business, technology and telecom concept, © Thissatan com; p.62 Young african male programmer writing program code sitting at the
Kotirat 123rf.com; p.23 cable on network switches background, © wklzzz 123rf.com; workplace with three monitors in the office. Image focused on the screen © Olena
p.26 Beautiful mature woman talking on phone at creative office. Happy smiling Kachmar 123rf.com; p.64 Real Python code developing screen. Programing workflow
businesswoman answering telephone at office desk. Casual business woman sitting abstract algorithm concept. Lines of Python code visible under magnifying lens ©
at her desk making telephone call and taking notes on notebook. © rido 123rf.com; piotrkt 123rf.com; Chapter 5 p.67 Modern city buildings and connection grid. 3d
p.26 Realistic usb cable connectors types set of images with modern types of usb rendering © Sergey Nivens 123rf.com; p. 69 Amazon Verification security © Dimarik16
plugs and sockets vector illustration © macrovector 123rf.com; p.27 corrupted data. dreamstime.com; p.75 Password stolen © Amsis1 dreamstime.com; p.76 Fingerprint
red binary code with missing pieces. computer technology problem virus error recognition technology for digital biometric cyber security with place for text ©
darknet and hacking background. computer language data transfers © suebsiri 123rf. Sergey Chuyko dreamstime.com; p.77 Closeup hands to press the ATM key in the red
com; p.28 Close up of a barcode © Alain Lacroix dreamstime.com; p.29 Closeup on cabinet. Finger pressing a pin code on a number pad. Security code on an pink ©
the screen with depth of field and focus on the padlock. The image is a security Rattanachot2525 dreamstime.com; p.77 Facial recognition by smartphone allows
concept in the search engine and web browser address. Hyper Text Transfer Protocol biometric authentication © Axel Bueckert dreamstime.com; p.77 Hotel door -
Secure (https). © ktsdesign 123rf.com; p.30 Data encryption concept with a screen full woman& x27;s hand inserting a magnetic stripe hotel key © Nuttawut Parasert
of hexidecimal information and padlock symbol © Anthony Brown 123rf.com; dreamstime.com; p.77 Credit or debit cards. Smart chip © Buradaki dreamstime.com;
Chapter 3 p.33 On board are capacitors resistors, slots, integrated circuits, diodes, p.78 Man open the door with NFC tag © Szabolcs Stieber dreamstime.com; p. 78
microprocessor © jk21 123rf.com; p.34 Macro view of CPU socket on PC computer male using a password generator to perform online banking. Security token for
motherboard © scanrail 123rf.com; p.36 colour cable bus isolated on white banking security. Concept of e-commerce, online business and data security ©
background © Nadezhda Tsarenko 123rf.com; p.36 DDR RAM memory module Valerio Rosati 123rf.com; p.80 Man unboxing latgest Apple Computers iPhone 11 Pro
isolated on white background © Volodymyr Krasyuk 123rf.com; p.38 CPU © Ifeelstock dreamstime.com; p.81 World map point and line composition concept of
Microprocessor. Flat style icon on transparent background © asmati 123rf.com; p.39 global business. Vector Illustration stock illustration © royyimzy istockphoto.com; p.81
Touching a monitor with navigation map of the modern car, close-up view © Olena Bitcoin symbol in flat design. stock illustration © iNueng istockphoto.com; Chapter 6
Kachmar 123rf.com; p.40 hands on keyboard © Maxim Evdokimov 123rf.com; p.40 p.83 Close-up Of A Man’s Hand Using Smart Home Application On Mobile Phone At
Numerical keypad © Laymul 123rf.com; p.41 Closeup of business woman hand with Home © Andriy Popov 123rf.com; p.84 Round temperature sensor on the hot water
mouse. Shallow depth of field. Selective focus © Aliaksei Verasovich 123rf.com; p.41 pipe © Denis Shipunov dreamstime.com; p.84 Microprocessor with motherboard
Woman freelance worker touching on laptop touch pad by her hand to select background © Yuliia Mols dreamstime.com; p.84 Piston or actuator as part of
something while working in cafe on weekday morning. Freelance business working hydraulic and pneumatic mechanism in machine. Technology © Ratmaner
lifestyle concept © Silatip dreamstime.com; p.41 Graphic designer using digital tablet dreamstime.com; p.85 Infrared motion sensor nightvision security camera © Alexxl66
and computer in office or home © Maksim Kostenko 123rf.com; p.41 Industrial control dreamstime.com; p.86 Picture of a woman flying a professional grade camera drone
panel with red trackball, close up photo with soft selective focus © Eugene Sergeev (UAS) © Printezis dreamstime.com; p.87 welding robots in a car manufacturer factory
123rf.com; p.41 A floating white Microsoft XBOX One controller isolated on a white © Sasin Tipchai 123rf.com; p.89 Fallen chess king as a metaphor for fall from power
background © Robert Klein 123rf.com; p.42 Hands of a doctor who uses the medical stock photo © Maudib istockphoto.com, p.89 People examining economic statistic.
ultrasound diagnostic machine © aksakalko 123rf.com; p.42 Designer using graphics Financial examiner. Vector stock illustration © AndSim istockphoto.com; p.89 GPS
tablet © Kaspars Grinvalds dreamstime.com; p.42 Playing video games on Xbox navigation concept © scanrail istockphoto.com; p.89 Car diagnostic concept Close up
console © Razvan Nitoi dreamstime.com; p.42 Customer satisfaction response People of laptop with OBD2 wireless scanner and retro car on gray gradient background 3d
hand on Touch screen Digital media device Business © Vtt Studio dreamstime.com; © kvsan istockphoto.com; p.89 Nutrition elements © Madmaxer istockphoto.com;
p.43 using scanner in office or library, closeup of hands scanning documents © p.89 Beautiful butterfly Tailed jay, Graphium agamemnon, in tropical forest © Jag_cz
anyaberkut 123rf.com; p.43 web camera © alexlmx 123rf.com; p.44 Computer istockphoto.com; p.90 room with rows of server hardware in the data center ©
microphone © Marius Scarlat dreamstime.com; p.44 Scanning barcode with bar code Timofeev Vladimir 123rf.com; Chapter 7 p.93 Abstract background image of a
reader isolated on white background. © Vchalup dreamstime.com; p45 Qr code or flowchart diagram on a white floor. Computing algorithm concept © infografx 123rf.
smartphone © Gualtiero Boffi dreamstime.com; p.45 Smiling asian office employee com; Chapter 8 p.111 Creative dark coding background with text. Programming and
looking at camera working with multiracial colleagues, happy young company future concept. 3D Rendering © Daniil Peshkov 123rf.com; Chapter 9 p.127 Pixelated
manager sitting at corporate workplace, cheerful team member posing with desktop effect of an image of a room of virtual database. 3aD Rendering © Alphaspirit
computer © fizkes 123rf.com; p.46 Customer satisfaction response People hand on dreamstime.com; p.128 Grocery shopping list till roll printout on a wooden table ©
Touch screen Digital media device Business © Vtt Studio dreamstime.com; p.46 Close Brian Jackson 123rf.com; Chapter 10 p.141 Abstract, close up of Circuits Electronic on
up projector in conference room with blurry people background © Mr.Smith Mainboard Technology computer background (logic board,cpu motherboard,Main
Chetanachan 123rf.com; p.46 LCD image projector © Antares614 dreamstime.com; board,system board,mobo) © Narong Rotjanaporn 123rf.com; p.142 Businessman
p.47 Compact laser home printer isolated on white background © Sergey Peterman entering safe code to unlock the door © stockyimages 123rf.com; p.149 Three happy
123rf.com; p.47 Printer prints business report on white isolated background. 3d © friends planning a travel on lineThree happy friends sharing on line content with
Maksym Yemelyanov 123rf.com; p.48 The 3D printer prints blue plastic model © Olga multiple devices sitting on a sofa at home Happy woman sitting on sofa and using
Ilina dreamstime.com; p.48 Small computer speaker isolated © Alexgerbergolts mobilephone at home, enjoying content on cellphone, chatting with friends, sharing
dreamstime.com; p.48 Digital camera on white © Yury Shirokov dreamstime.com; mobile devices with friends. Line art style indoor house. Happy friends using cellular,
p.49 Digital thermo-hygrometer wires with an external sensor for measurements © sitting on sofa at home, browsing internet and sharing content, and consulting a
Pavel Kruglov dreamstime.com; p.51 Harddisk drive (HDD) with top cover open on guide sitting on a sofa at home © Antonio Guillem 123rf.com; p.158 Young teen girl
white background © Parinya Agsararattananont 123rf.com; p.51 External Hard Drive in the elevator, presses the elevator button © Valeriy_G istockphoto.com

SB CS PP.indb 3 14.5.21. 14:13


This book is designed to help you build your knowledge and understanding of essential Computer Science concepts. It will
also enable you to appreciate the application of Computer Science in your everyday life. This Student’s Book is part of the
Marshall Cavendish Education suite of resources that will support you as you follow the Cambridge IGCSETM and IGCSE (9-1)
Computer Science syllabuses (0478/0984) and prepare for your examinations.
Chapter opener
CHAPTER introduces the topic and

4 Software key learning goals.

COMPUTER SCIENCE WATCH*

makes learning ‘come alive’. The videos can be launched from


a smartphone or a tablet by scanning a page using the MCE
COMPUTER SCIENCE WATCH

Scan the page to watch a clip on


Cambridge IGCSE App.
the differences between system and
application software.
Before watching discuss what you expect
Please refer to www.mceapps.com for user guide and further
to see or hear.
information.
QUESTIONS *As the Watch videos are authentic and therefore reflect real-life
• What is the link between hardware and
software?
situations, they might in some instances contain content that is beyond
• How is software essential to the operation
of a computer? the scope of this syllabus. Always refer to the appropriate syllabus
At the end of this chapter, you will be able to:
• How do humans use software to interact
with computing devices? document for the year of your examination to confirm the details and for
understand the difference between system software and application • What is programming and how do pieces
software of software begin their existence?
more information. The syllabus document is available on the Cambridge
define the role and basic functions of an operating system
identify the hardware, firmware and operating systems that are used
International website at www.cambridgeinternational.org.
to run applications software
define the role and operation of interrupts Content in this feature has not been through the Cambridge
identify the difference between a high-level language and a low-level
language Assessment International Education endorsement process.
understand the advantages and disadvantages of each type of
language
define the two types of translator: compilers and interpreters
identify the advantages and disadvantages of each type of translator
understand what an integrated development environment is used for,
including its common functions QUESTIONS
59
assess your prior knowledge on the topic.
IGCSE_CS_TB_Chapter_4.indd 59 13.5.21. 16:32

Chapter 10

DEFINITION DEFINITION
. Logic Gates
Logic gates: the basic Logic gates are the basic building units of any digital circuit. Today, these circuits are used in almost

explains key terms used


units of a digit circuit every computer system. From elevators to washing machines, logic gates are used all around you.
that control the flow of
electronic signals.

in Computer Science.

WORD ALERT

Words commonly associated


with the topic are highlighted
in red and explained in a WORD ALERT
Digital circuit used to open electronic door.

simpler way. This also helps Combination: a joining


This chapter will explore the types and functions of common logic gates.
There are a number of different types of logic gate, with different logic rules. The combination

you to be more familiar with


of different parts or of several logic gates forms a circuit, which allows for the design and performance in modern
qualities. computers. The gates receive binary data, apply a Boolean operation and then output a binary result.
Arithmetic: use of
the words and be confident in numbers to calculate an
outcome. Boolean Operations
using them. Equivalent: the same or
equal meaning.
The word ‘Boolean’ comes from Boolean algebra, which is the basis of computer arithmetic and
especially logic gates. There are only two Boolean values: true and false. They have equivalents in
normal language and in binary notation.
Boolean expressions can compare data of any type as long as both parts of the expression have the
HELPFUL NOTES
same data. In computer science, Boolean expressions can be used in programming and produce
Be careful not to confuse
Boolean values when evaluated. Boolean values are either true or false:
the Boolean operator ‘+’
with ‘+’ , which means Boolean value Binary value Synonyms
LINK ‘plus’ in normal maths.
True  On Yes Positive
False  Off No Negative

leads you to exercises in


There are also three logical operators: NOT, AND and OR. The Boolean operators for these are AND ‘•’,
OR ‘+’, and NOT ‘ ’, which is written above the letter.

the Workbook for further


Ā means NOT A.
A • B means A AND B.

practice. A + B means A OR B.
Logic gates use both Boolean values and operators.

142 Logic Gates and Circuits

iv IGCSE_CS_TB_Chapter_10.indd 142 13.5.21. 16:32

SB CS PP.indb 4 14.5.21. 14:13


Chapter 2
ENRICHMENT This type of data transmission occurs when a computer or device is connected to another computer
or device using a single data channel. Data is transmitted one bit at a time, sequentially, down
ENRICHMENT the channel.
An example of this type of data transmission occurs when a computer is connected directly to a modem.
Can you find out when
promotes deeper thought serial and parallel ports
were no longer included
One of the advantages of using a serial transmission method is that it is very reliable for transferring
data over longer distances, although sometimes it is not the most practical. There are also much

by: offering snippets of in computers? What


replaced them and why?
fewer errors in serial transmission, as bits are sent one at a time, and only one single channel is
required to achieve this transmission. Thus, this is a lower cost method of transmitting data.

information to supplement The disadvantage of a serial transmission is that transmission speeds can be slow as only one
channel is being used to transfer data.

your knowledge; providing Parallel Data Transmission


activities which help
reinforce learning; or posing
challenging questions to
encourage you to apply
the concepts learnt to Computer
Bits
Printer

various contexts. Figure . Parallel transmission. (Multiple)

REFLECT Parallel data transmission is where multiple bits of data are sent at the same time along different
channels in the same cabling.
Most modern printers
now are connected to An example of this type of data transmission is where a computer is connected directly to a printer.
computers using network The advantages of this type of transmission is that faster data transmission takes place because of the
cables and data is multiple channels being used. The disadvantages are that this type of transmission is more expensive
transmitted much faster
and synchronisation errors can occur due to the separation of data across different channels.
LINK
this way.

Simplex Data Transmission WB


REFLECT Input

Computer also leads you to exercises


stimulates you to be aware of in the Workbook for further
your own thought processes Figure . Simplex transmission.
Unidirectional
practice.
and explore different ways of QUICK CHECK

What other devices


Simplex transmission is a one-directional (or unidirectional) mode of data transmission. The data will
only go one way, and the receiver of the data does not send any data back to the sender.
solving problems. can you think of that
use unidirectional data
An example of this type of transmission occurs between a keyboard and a monitor. The keyboard
sends input data to be displayed on a monitor, but the monitor does not send any data back to the
transmission?
keyboard.
The advantage of simplex transmission is that the process can use the full bandwidth of the Chapter 10
channel. The disadvantage of this transmission type is that it is not possible to engage in two-way
transmission using this method, and most forms of communication rely on this to be successful. Activity

1 Now do the same for this situation. You can skip some steps if you don’t need them.
Tip: the circuits are normally on so something needs to happen if they go off.
QUICK CHECK
• An alarm makes no warning sound if the door is closed and the window is closed. There are
24 Data Transmission hidden switches on the door and window through which a current is constantly passing. If Write the Boolean algebra
someone opens the door or window, the alarm sounds. expression for NAND,
2 Name the logic gates represented by these truth tables: NOR, XOR.
IGCSE_CS_TB_Chapter_2.indd 24 13.5.21. 16:33

a Inputs Output

Worked Example A

B

X

demonstrates how to solve 






problems by applying
  

WB LINK
b Inputs Output
concepts learnt. A B X
Consolidate your
understanding by
   completing the Exercises
   1-2 from pages 123-129
in the Workbook.
  
  

Chapter 10
Worked Example
We use Boolean logic all the time. Look at this situation using Boolean operators:
You have decided that you will do extra study if you are falling behind at school. You also decide
that you will do extra study even when you are not behind if your friend asks you to study
together. Express this using Boolean operators.
WORD ALERT
Solution
To express this formally and logically we need two pieces of information to make our decision Formally: officially /

Activity gives you


and another piece to represent the result of the decision. We can name our information like this: explicitly.

Information needed to make decision

opportunities to
(behind at school) = TRUE if fall behind. If not, FALSE.
(friend asks you to study) = TRUE if friend asks you to study. If not, FALSE.
Result
(do extra study) = TRUE if we decide to do extra study. If not, FALSE. apply what you
Our logical expression is then:
(do extra study) = (behind at school) OR (NOT (behind at school)) AND (friend asks you to study) have learnt and
This expression uses the three Boolean operators: NOT, AND, OR.
assess what you
Activity know.
1 Write a logical expression like the example above for this given scenario.
There are two methods of getting to your part time job on time. You can get the bus but only if
Logic Gates and Circuits 149
you wake up before .am. If you wake up after this time, you will need to ask your parents to
take you in the car. If you wake up before .am but your parents offer to take you, then you will
always say yes as it is easier. IGCSE_CS_TB_Chapter_10.indd 149 13.5.21. 16:32

2 Draw the Boolean algebra symbols for the following:


a) A NOT B
b) A AND B
c) A OR B
HELPFUL NOTES

Types of Logic Gate


In all logic gates except
the NOT gate, there are
HELPFUL NOTES
two inputs. The inputs or
There are three basic types of logic gate that will be examined in this chapter: NOT, AND and OR. outputs have two possible
states: a value of 1 or a
value of 0.

supports your learning


NOT AND OR
WORD ALERT by providing tips and
The left side of the logic gate is referred to as the input and the right side as the output.
We can use a truth table to show the function of the logic gate. Each of the logic gates has a different
Referred: denoted /
identified.
highlighting important notes
truth table. These truth tables display all possible input combinations and the correct output. that you need to be aware of.

Logic Gates and Circuits 143

IGCSE_CS_TB_Chapter_10.indd 143 13.5.21. 16:32


v

SB CS PP.indb 5 14.5.21. 14:13


Chapter 10
Here is the truth table for the OR gate above:
REFLECT
Inputs Output
A B X If someone asks you, ‘Do
you want a soda or some
  
water?’, you can’t answer
   ‘Both, please’. If you could
   have both that would be
   an inclusive use of OR. Is
the OR gate inclusive or
Logic notation: X = A OR B exclusive?
Boolean algebra: X = A + B
Out of the four possible output states, the only time output X will be  is when both the inputs
A and B are .
An inclusive OR is what is shown in the truth table if either A or B is True, or if both are True, then the
statement value is True.
An exclusive OR only returns True when A OR B is True only.

Worked Example
A security light outside a house comes on after .pm or if it is dark. Make a table showing WORD ALERT
the operation in normal language with corresponding Boolean and binary values. Make the
resulting truth table and choose the logic gate that will make this happen. Condition: the state of
something in relation to
QUICK CHECK
Solution its appearance, quality or
We have to state the conditions under which the light will come on: working order.
if it is after .pm
if it is dark
Then we convert these into the Boolean values ‘True’ and ‘False’: serves as a checkpoint to check
your understanding of concepts.
it is after .pm = Yes/True/Positive
if it is dark = Yes/True/Positive

Rate your confidence level


QUICK CHECK
Next we add the binary values:
it is after .pm Yes True Positive  In all logic gates except

Let’s Map It provides


it is dark Yes True

Then we make the truth table. The inputs are ‘it is after .pm and ‘it is dark’:
Positive  the NOT gate, there are
two inputs. The inputs or
outputs have two possible
in your answer by drawing a
a visual summary of Inputs
states. What are they?
pointer on the confidence meter.
it is after .pm it is dark
the concepts covered The light coming on is the output:

to help you integrate Inputs Output

your learning and form it is after .pm it is dark

Remember that the light will come on if either of the conditions is true:
the light comes on

connections between Inputs Output Let’s Review offers questions


different concepts. it is after .pm
No
No
it is dark
No
Yes
the light comes on
No
Yes
to test your understanding
Yes
Yes
No
Yes
Yes
Yes and gives you consolidated
Logic Gates and Circuits 145 practice.
IGCSE_CS_TB_Chapter_10.indd 145 13.5.21. 16:32

Chapter 4 Chapter 10

Let’s Map It
Let’s Review
 What logic gate matches these truth tables?

HARDWARE SOFTWARE A B X A B X

     
     
     
Software and hardware are essential to work together.
     

 Label the following logic gates:

SYSTEM APPLICATION

 Draw the logic circuit for the following statement X = (A AND B) AND (NOT C).
Allows a Allows a  Complete a combined truth table including any intermediate outputs for the following: <?>
computer to computer to
function be used A P
AND
B
OR X

C
Operating System Applications are required to enable a user to  Draw the correct logic gate circuit and truth tables to match these Boolean algebra expressions:
Enables a user to interact with the computer. carry out tasks and work.
A˙B A+B Ā
 Draw the logic circuit diagram and corresponding truth table represented by the below Boolean algebra epressions.
Consider the logic statement:
X =  If [(A is NOT  OR B = ) NAND C is ] NOR [(A is  AND C is ) NAND B is ]

Interrupts All software starts as code


B X
A stop in a process needing a user or program input.

1 Python Perl C++ Java C# C


2 Handled in order
3 of priority.
4

A B C Working space X
Integrated Development Environment Low- and high-level languages   
X
  
1
if a == 10:   
2
3
00110 111001 b += 1   
4
Low High   
5
6   
Code 7
Editor 8 Simulation   
Translator
9 Compiler/Interpreter   
10
11

Software 65 162 Logic gates and circuits

IGCSE_CS_TB_Chapter_4.indd 65 13.5.21. 16:32 IGCSE_CS_TB_Chapter_10.indd 162 13.5.21. 16:32

The following are also included at the end of the book:


• Answers – provided for questions in Let’s Review (only numerical and short answers are included)
• Glossary – provided to give you a list of the vocabulary words and definitions highlighted in Word Alert
• Index – provided to help you search for key terms and phrases in the book

vi

SB CS PP.indb 6 14.5.21. 14:13


Contents

vii

SB CS PP.indb 7 14.5.21. 14:13


SB CS PP.indb 8 14.5.21. 14:13
CHAPTER

1 Computer Systems

QUESTIONS

• What is data?
• How is data represented by computers?
At the end of this chapter, you will be able to: • How is data stored and compressed for use?
convert between the binary, denary and hexadecimal number systems
understand why hexadecimal is used for representing data
add two -bit binary numbers and know why overflow happens
perform both a left and right logical binary shift
use two’s compliment to represent positive and negative binary numbers
understand how a computer represents text, sound and images
identify the different data storage measurements
understand how to calculate the size of a file
understand why files need to be compressed
explain how files are compressed using lossy and lossless compression methods

SB CS PP.indb 1 14.5.21. 14:13


Chapter 1
Computers and computing devices are capable of processing millions of pieces of information every
second. Computers read and write an enormous variety of information; in order for the processing
WORD ALERT
to happen efficiently, that information must be broken down into code that every computer can
Efficiently: to perform understand. Information used by a computer is called data.
something in a The code that computers and machines use to process information is called binary. This is a number
well-organised and system that only uses two digits,  and . All data that a computer is required to process has to be
competent way. converted into binary in order to be understood. This chapter will explore how computer systems
represent data in a variety of ways.

DEFINITION

Binary: a number system


that contains just 2
. Number Systems
numbers, 0 and 1, and
the number system
In order to understand the binary number system,
that a computer uses to
we must first understand the decimal, or denary,
process data.
number system that we are used to. There are several
different theories about how ancient civilisations
began counting in decimal numbers. One theory is
QUICK CHECK that people began counting using their hands, and
we have two hands, each with four fingers and one
What is the difference
thumb making up ten digits.
between a base-10 and a
base-2 number system?

.. Denary Number System Humans probably started to count using


the ten digits that they had on their hands.

The denary system is a base- system, meaning that there are ten digits that form the basis of the
place value system. All numbers in the denary system are formed from , , , , , , , ,  or , and
the place value of each position of the decimal numbers is ten times larger than the place to its right,
written in powers – , ,  and so on.
WORD ALERT

Powers: the product


Worked Example
obtained when a number We can represent the denary number  as in the table below:
is multiplied by itself a
certain number of times. Hundreds Tens of
Thousands Hundreds Tens Units
of thousands thousands
     
     
 ×  =   ×  =   ×  =   ×  = 
  ×  = 
  ×  = 
  
 +  +  +  +  +  = 

.. Binary Number System


Binary is a base- system, meaning that only two digits form the basis of the place value system. All
numbers in the binary system are formed from either  or . The place value of each position of the
HELPFUL NOTES binary numbers is two times larger than the place to its right, otherwise written in powers, , , 
and so on.
When reading binary
numbers, it is important You will notice in the worked example that the columns increase by a power of  from the first
to read them from right column as you read from right to left.
to left.

2 Computer Systems

SB CS PP.indb 2 14.5.21. 14:13


Chapter 1
Worked Example
We would represent the binary number  in the table below:

    

     DEFINITION
    
Transistors: a small
 ×  = 
 × = × =
 × =
  ×  =  electronics device that
 +  +  +  +  =  amplifies electrical
current.
Therefore, the binary number  represents  in denary.

Computers use the binary system because all of the processing takes place using components LINK
such as registers and memory. These components are made up of transistors that can hold either
See Chapter 10 for
an electric charge () or no electric charge (). Logic gates are used to make decisions about the
more information about
processing of data, and they have two options – on () or off (). Depending on the gate, data bits are logic gates.
either kept the same, or switched from  to  or  to  for the operation being carried out.

.. Hexadecimal Number System REFLECT

The hexadecimal number system is another number system that computers use for processing. Have you ever seen what
looks like a hexadecimal
• It is different from the binary and denary systems as it is a base- system.
number on your
• It is similar to the denary system as it begins with the digits –, but it also uses the alphabetic computer? If you find one
characters A–F to form the remainder of its place values. try and convert it to a
Computers only use binary code, however the conversion to hexadecimal is mostly for human denary number.
benefit as this conversion shortens the long binary codes. This is illustrated by the conversion table
below. Note that the first ten digits are identical.
WB LINK
Denary                
Hexadecimal           A B C D E F Consolidate your
understanding by
completing Exercise 1,
We will discuss the uses of these in section .. page 1 in the Workbook.

. Binary, Denary and Hexadecimal LINK

Conversions Section 1.3.

To better understand how a computer carries out the processing of numerical information, it
is important to know how to convert numbers from one system to another. There are various
mathematical approaches to these conversions.

.. Converting a Denary Number to Binary WORD ALERT

An easy way to convert a denary number into binary is to use the ‘divide by ’ method: Remainder: the number
left over in a division
• Divide the number by  each time and note the remainder. in which one quantity
• When you are unable to divide by  any further, the sequence of remainders becomes the binary does not exactly divide
number that represents the denary number you began with. another.
• These remainders should be read from the last division to the first.

Computer Systems 3

SB CS PP.indb 3 14.5.21. 14:13


Chapter 1
For example:
29
 divided by  =  remainder 
 divided by  =  remainder 
 divided by  =  remainder  Read in this
 divided by  =  remainder  direction
 divided by  =  remainder 
Therefore,  in binary notation would be .

.. Converting a Binary Number to Denary


When converting a binary number to denary, it is important to use the rules of place value. Each time
you move a place to the right, the places increase in value by  times the amount of the previous place.

Tens thousands Thousands Hundreds Tens Units


LINK WB
s s s s s
Consolidate your
understanding by So, applying place value to a denary number like  will look like this:
completing Exercise 2,
page 2 in the Workbook. Tens thousands Thousands Hundreds Tens Units

s s s s s


    
 ×  =   ×  =   ×  =   ×  =  ×=
 +  +  +  +  = 

LINK Worked Example


Section 1.1.2. Binary place values can be written in a similar way (see section ..), but the difference here is
that the places double in value from to the previous place.

    
HELPFUL NOTES
Therefore, you can apply place value to a binary number like  as follows:
You can continue writing
place values for binary     
numbers and keep
doubling the places in     
each column. The normal
length of number is 8 bits.  ×  =  ×= ×= ×= ×=
 +  +  +  +  = 

So, using the mathematics above, the binary number  is  in denary.

ENRICHMENT
Activity
Can you write your date Show your working out for these exercises.
of birth in binary?  Convert the denary number  into binary.
 Convert the denary number  into binary.
 Convert the binary number  into denary.
 Convert the binary number  into denary.

4 Computer Systems

SB CS PP.indb 4 14.5.21. 14:13


Chapter 1
.. Converting a Denary Number to Hexadecimal
Using Binary QUICK CHECK

To convert a denary number to hexadecimal, it is important to know the binary equivalents of the What are the differences
between binary and
first  hexadecimal digits (see section ..).
hexadecimal?
Denary number Hexadecimal digit Binary code
  
  
  
  
  
   LINK
  
Section 1.1.3.
  
  
  
 A 
 B 
 C 
 D 
 E 
 F  DEFINITION
The table shows that converting any of the first  denary digits into its hexadecimal equivalent is
Nibble: a set of four
straightforward. However, converting denary numbers larger than  requires combining the -bit
binary bits.
binary nibbles in the binary code column.
For example, the denary number  in hexadecimal is created by combining the binary nibble
equivalent to denary number  and the binary nibble equivalent to denary number .
HELPFUL NOTES
Combining two binary nibbles in this way creates an -bit binary number, or a byte.
Bytes are a common
Denary number Binary nibbles Hexadecimal notation
measurement of bits.
    ( + ) Octets, or groups of 8, are
used to represent different
types of data.
Worked Example
To convert the denary number  to hexadecimal you would do the following: LINK
• Convert the denary number  to -bit binary using the ‘divide by ’ method, which becomes
 (see section ..). See section 1.2 to
• To write the denary number as an -bit binary number rather than a binary number, add refresh your memory
three s to the front of the five-digit number – so  becomes . For this conversion about denary to binary
conversion.
we can then split the two sets of four binary digits into nibbles, to get  .
• Once you have constructed the -bit binary conversion, use the table above to match the
two nibbles to the hexadecimal column. In this instance, the nibble  is the equivalent of
the hexadecimal digit , and the nibble  is the equivalent of the hexadecimal digit F.
LINK
Denary number Binary equivalent -bit binary Hexadecimal notation
Section 1.2.1.
    F
Therefore, combining the two digits gives the hexadecimal code F.

Computer Systems 5

SB CS PP.indb 5 14.5.21. 14:13


Chapter 1
.. Converting a Hexadecimal Number to Denary
Using Binary
In the same way that you can use binary to convert from denary to hexadecimal, you can also
convert the opposite way:
• Take the hexadecimal number, separate the digits, and then convert those digits back to
LINK
binary nibbles.
Section 1.2.2. • Once combined into an -bit binary number, use the place value method (see section ..) to
convert the binary number back to denary.

Worked Example
To convert the hexadecimal number C to denary, do the following:
LINK . Separate the two parts of the hexadecimal number into  and C.
See section 1.2 to remind
. Using the table in section .., convert the two hexadecimal digits into their binary
yourself about the place nibble equivalents – hexadecimal digit  is equivalent to the binary nibble , and the
value method. hexadecimal digit C is equivalent to the binary nibble .
. The two binary nibbles combined make the -bit binary number .
. Put the -bit binary code into a binary place value table:

       

       
 ×  =   ×  =   ×  =   ×  =  ×= ×= ×= ×=
 +  +  +  +  +  +  +  = 

Therefore, the hexadecimal code C is equivalent to the denary number .

Activity
Show your working out for these exercises.
 Convert the denary number  into hexadecimal, using binary to help you.
 Convert the denary number  into hexadecimal.
 Convert the hexadecimal number F into denary, using binary to help you.
 Convert the hexadecimal number A into denary.

. Examples of the Use of Hexadecimal


Numbers in Data Representation
Data in its most basic form has to be converted to binary so it can be processed by a computer.
However, hexadecimal numbers are useful for a number of purposes, and are easier for humans to
read than long strings of binary bits.

6 Computer Systems

SB CS PP.indb 6 14.5.21. 14:13


Chapter 1
Hexadecimal numbers can be found in computer science in the following examples:

MAC Address
Media Access Control
A number that identifies a network interface
controller of a device on a network.
:::d::a

Error codes
Often operating system errors are represented
HEXADECIMAL with hexadecimal numbers for reference.
NUMBERS xCDL

HTML Colour Codes


Websites use colour codes to represent one of
the  million colours in the palette.

IPv6 Address
Internet Protocol version 6
A number that identifies locations of devices for
the routing of data packets across the internet.
:da:ae::

. Binary Addition LINK


WB

Addition is one of the most common mathematical operations a computer performs. To appreciate Consolidate your
this, it is important to understand how to carry out binary addition. understanding by
completing Exercises 3
Before attempting binary addition, we must look at the similarities with denary addition because the
and 4, pages 5-10 in the
two processes are alike. Workbook.

.. Adding Two Binary Numbers Together


To add together the two denary numbers  and , we would place them one above the other,
draw a line underneath the sum and add the columns, starting from the numbers on the right. REFLECT
Where the sum of the numbers in the column equals  or more, we carry the tens underneath the
next column according to place value. Note the similarities
   between binary and
+   denary addition –
always start with the
  
  right-hand column.
The total of  +  is therefore .
Adding together two binary numbers is a very similar process. However, it is important that the two
binary numbers have the same number of binary digits.

Computer Systems 7

SB CS PP.indb 7 14.5.21. 14:13


Chapter 1
Worked Example
Add together the binary numbers  and  as follows:
• Write the numbers out in columns, as if you were adding two denary numbers.  would
become .
• Begin from the furthest right and add the numbers in each column.
  
+  
  
The binary number  is equal to  in denary, and the binary number  is equal to  in denary.
 +  =  and the binary number that is produced by the addition () is equal to the denary
QUICK CHECK number .

What would you need to


do in the addition to add As with denary, we carry values when adding two s in the same column.
two 1s in one column?
Worked Example
Add the binary numbers  and  as follows:
• Write the numbers out in columns as if you were adding two denary numbers.
• Begin from the furthest right and add the numbers in each column.
   
+    
   
When you add the two s in the third column, this becomes a , and  is carried across to the
next column. This also then produces an addition of two s, which means that a new column
has to be created.
The binary number  is equivalent to the denary number , and the binary number  is
equivalent to the denary number .
 +  =  and the binary number that is produced by the addition () is equal to the
denary number .

.. Overflows
As we learnt in the previous section, adding together binary numbers can often lead to the creation
of an additional column on the left-hand side of the number.

Activity
Show your working out for these exercises.
 Convert the denary numbers  and  to binary and perform an addition on the two numbers.
 Convert the denary numbers  and  to binary and perform an addition on the two numbers.
HELPFUL NOTES

The number 255 is To apply this theory to a computer, if a register in a central processing unit (CPU) had a capacity
significant in 8-bit binary of  bits, the largest binary number that it could possibly hold would be , equivalent to the
as it is the largest number denary number .
that can be represented
in an 8-bit binary octet. If one more bit was added to this number, it would push the number above the capacity of the
register and would cause an overflow error.

8 Computer Systems

SB CS PP.indb 8 14.5.21. 14:13


Chapter 1
This is highlighted by the following sum, which is a binary addition of  + :
       
+         

       
As the column additions carry forward a  each time, eventually a ninth column is added. This creates
a total that becomes a binary number consisting of  bits, one more than the maximum capacity of
 bits. In this instance, the CPU will drop the extra digit, or the overflow digit, because it has nowhere
WORD ALERT
to store it. The computer would then think that  +  = .
This action would cause an overflow error, which means that there is not enough capacity to carry Overflow: the generation
out an instruction, and this may make the computer processing unstable or stop. of a number or other data
item that is too large for
Most modern computing devices have a much larger capacity than  bits, however, overflow errors the assigned location or
can still occur if the arithmetic and additions push the numbers being returned above that capacity. memory space.
Shift: movement either

.. Binary Shifting to the left or right.

So far we have only looked at addition. Computers are capable of carrying out logical arithmetic on
the binary numbers that they process, and for multiplication and division a CPU uses a process called
binary shift. To understand this, we must refresh our memory about binary place value. When we
converted a binary number to denary, we used the base- table below:

        WB LINK

We will now explore multiplication and division, using the binary place value table to understand the Consolidate your
process of shifting, or logical shifts. understanding by
completing Exercise 5,
page 10 in the Workbook.
... Multiplication
For a CPU to multiply a binary number, the number needs to be shifted to the left and will fill the
remaining gaps with zeros. For example:
REFLECT
• multiplying by  shifts the digits one place to the left
• multiplying by  shifts the digits two places to the left How many shifts to the
• multiplying by  shifts the digits three places to the left left would take place if
you were multiplying a
You will notice that multiplications happen in line with the order of place value in the base-
binary number by 32?
sequence.

Worked Example
Take the binary number , equivalent to  in denary and a multiplication of  × .
We would begin with the number written like this:

       

   
Multiplication by  requires the digits to be shifted to the left by one place, and the gap is filled
with a zero:

       

    
Therefore, the left binary shift operation gives a binary number of , equivalent to the
number  in denary.

Computer Systems 9

SB CS PP.indb 9 14.5.21. 14:13


Chapter 1
... Division
For a CPU to divide a binary number, the number needs to be shifted to the right:
• dividing by  shifts the digits one place to the right
• dividing by  shifts the digits two places to the right
• dividing by  shifts the digits three places to the right
You will notice that divisions happen in line with the order of place value in the base- sequence.

Worked Example
Take the binary number , equivalent to  in denary and a division of  ÷ .
We would begin with the number written like this:

       

     
A division by  requires the digits to shifted to the right by one place:

       

    
Therefore, the left binary shift operation gives a binary number of , equivalent to the
number  in denary.

... Binary Shifts with -bit Binary Numbers


We have learnt about binary shifts left and right when multiplying and dividing with small binary
REFLECT numbers. It is important to also learn what happens when multiplying or dividing -bit binary numbers.
How many shifts to the This is because registers contained within the CPU (see Chapter ) often have -bit limits on the
right would take place amount of data they can hold at any one time. If an -bit binary number needs to be multiplied the
if you were dividing a shifting process can cause bits to be lost at one end of the register, and zeros added at the opposite
binary number by 8? end. This process is known as losing the ‘most significant’ bit and can cause data to lose precision. It
also provides the mathematical explanation for an overflow error.

LINK Worked Example


See Chapter 3 to learn Multiplying an -bit binary number by 
about the role of registers If we wish to multiply the binary number  (the equivalent to denary number ), we
in the CPU. would first write the number in the place value table:

       
HELPFUL NOTES        
The most significant We would then perform a shift of one place to the left:
and the least significant
bits are at the far left or        
right of a binary number,
respectively.        
1
However, what has happened to the  that was placed in the furthest-left column?
LINK
The multiplication shift produces the binary number  – the equivalent to denary
number  and not , which arithmetic suggests would be returned. This number is larger
Section 1.4.2.
than the  () capacity that the -bit register can store (see section ..).
This bit is called the ‘most significant bit’, and when it is shifted beyond the furthest-left column
the binary data that is stored loses precision due to overflow.

10 Computer Systems

SB CS PP.indb 10 14.5.21. 14:13


Chapter 1
The same process can occur when dividing an -bit binary number. There is also a further level
of complexity, because performing a logical right shift can cause a binary number to become
a decimal.

Worked Example
Dividing an -bit binary number by .
If we wish to divide the binary number  (the equivalent to denary number 189), we
would first write the number in the place value table:

       

       

We would then perform a shift of five places to the left:

       

       

However, what has happened to the binary numbers that have dropped off from the right-hand
column?
The division shift produces the binary number  – the equivalent to denary number  not the
decimal number . that arithmetic suggests would be returned. This is because working with
binary in this way does not use decimals, only positive binary integers. The decimal part of the
REFLECT
number is therefore discarded.
These bits are called the ‘least significant bits’ and when they are shifted beyond the right- Why do you think that
hand column, just like with multiplication, the binary data that is stored loses precision due decimal numbers are
to overflow. discarded when dividing?

Activity
Show your working out for these problems.
 Multiply the binary number  by .
 Multiply the binary number  by .
 Divide the binary number  by .
 Divide the -bit binary number  by .

.. Two’s Complement WB LINK

We have looked at positive numbers and the way that they are represented by a CPU. However, Consolidate your
a processor can also represent negative numbers, and there are a few ways it handles this understanding by
process. completing Exercise 6,
One of the methods a processor can use to represent negative numbers is called two’s page 11 in the Workbook.
complement. We can use a reference table to help understand this method.

Computer Systems 11

SB CS PP.indb 11 14.5.21. 14:13


Chapter 1
Binary numbers and place values
Denary equivalent
       
        –
        –
        –
        –
        –
        –
        –
        –
        
        
        
        
        
        
        
        

To represent negative numbers, it is important to think about the place value of the furthest-left bit
in a different way. Processors can be set up to see the bit in the eighth column as a sign bit (shaded).
• If the digit in the sign bit column is a , this indicates that the binary number being represented
is positive.
• If the digit in the sign bit column is a , this indicates that the number being represented is negative.
WORD ALERT
You will also notice that for each of the -bit positive binary numbers represented in the table, their
Inverted: reversed or negative opposite numbers have had their bits inverted. The final step in this process once all of the
transformed into its bits have been inverted is to add  to the calculation when completed.
corresponding opposite.

Worked Example
Converting a positive binary integer to a two’s complement -bit integer
To convert the binary number  ( in denary) to a positive two’s complement integer, put
the number into the place value columns, ensuring that the left-hand digit is a  (to show that
positive  is represented).

       

       
The digit in the shaded left-hand column is the sign bit, and  represents a positive integer. As we
learnt earlier, adding the place columns as shown gives us the denary equivalent:  +  +  = 
HELPFUL NOTES
Converting a positive two’s complement -bit integer to a binary integer
The furthest-left column To convert positive  from a two’s complement integer to a binary integer, we essentially need
represents the sign bit; to reverse the process above. We would represent the number  as follows:
this tells us whether a
number is positive or        
negative. If the column
contains a 0 the number        
is positive, if it contains a
The  in the left-hand column indicates a positive number, and the positive two’s complement
1 the number is negative.
-bit binary number can therefore be written as .

12 Computer Systems

SB CS PP.indb 12 14.5.21. 14:13


Chapter 1
Converting a negative binary integer to a two’s complement -bit integer
To represent the binary number  ( in denary) as - and a negative two’s complement
integer, put the number into the place value columns, but invert the s to s and s to s. This
gives you the integer’s complement.

       

       
This time, the sign bit column becomes - as there is a  in that column.
The calculation then becomes – +  +  +  +  = – and  is added to the product to ENRICHMENT
make –. – =  +  = .
Why do you think
Converting a negative two’s complement -bit integer to a binary integer that we omit the
In order to achieve this, we would essentially reverse the above process. To convert - we inverse of the binary
would first of all write out the table for + and invert the bits. This would then give us the number representing 0
negative two’s complement -bit binary number . (00000000)? What would
the denary equivalent
        of 11111111 be within
the context of two’s
        complement?

. Text, Sound and Images


Modern computers are required to represent data in many different forms. The most basic form
is textual data. However, as we live in an increasingly digital world, the information and data that
humans require to be processed becomes ever more complex.

.. Text Representation


Every character that is input into a computer must be represented by binary code, including
the spaces we type between words and the special characters we use for punctuation. As
textual communication is vital for users around the world, it is important that computers have a
common set of characters that are recognised by a variety of systems. These are called character
sets, and the most common are American Standard Code for Information Interchange (ASCII)
and Unicode.
ASCII code uses seven binary bits to represent all the commonly used characters. This provides a
character set that has  different characters, made up as follows:
•  upper case letters
•  lower case letters
• Digits
• Punctuation marks
The basic form of ASCII does have restrictions, as it does not allow for the representation of
characters such as á or ê, which are commonly used characters in different languages. So Extended REFLECT
ASCII was created, which allows  characters to be represented, meaning that characters from
languages such as French and Spanish could be stored. What do you think control
codes are used for?
As textual communication developed further and became increasingly global, even Extended ASCII
was too restrictive for all of the different languages and characters required.

Computer Systems 13

SB CS PP.indb 13 14.5.21. 14:13


Chapter 1

Inserting a special character in Word is made possible by using the Unicode character set.
HELPFUL NOTES Computers began to be programmed using Unicode to represent text. Unicode uses -bits to
represent the characters in its set, which enables over , characters. In this way, languages such
An emoji is made up as Chinese and Arabic, which have many additional characters, can be stored, displayed and shared.
of combinations of Unicode can also display the pictorial symbols known as ‘emojis’, which are used in the world of
different symbols, usually instant messaging and texting.
beginning with a colon.

.. Sound Representation


WORD ALERT
Just as text can be represented by binary, so too can sound. For a computer to successfully process
Analogue: using sound, the analogue signal input has to be converted into a digital signal. Sound is normally
signals or information captured by a microphone, and a piece of software will capture it and convert the analogue to
represented by a digital. This recording is called a sample.
continuously variable
physical quantity. The sample is recorded over a period of time measured in seconds. The sample generates a
continuous sound wave that is a measure of amplitude over time.

DEFINITION 9
8
Amplitude: the strength of
a sound wave, measured 7
at the highest level. 6
Amplitude

5
4
3
2
1
0
1 2 3 4 5 6

Time

14 Computer Systems

SB CS PP.indb 14 14.5.21. 14:13


Chapter 1
The conversion software records the amplitude at each moment in time during the sample. Each
amplitude number (denary) is then converted into binary and stored.
DEFINITION
The example in the graph above shows one sample being converted into a sound wave. However,
the recording software is capable of taking multiple samples every second. This number is called the Hertz: frequency of
sample rate and it is measured in hertz, or cycles per second. The greater the sample rate, the larger samples, measured in
the audio file that is created by the software. cycles per second.

Sample rate is also very important in determining the sound quality of the audio – if the rate is too
low, the sound quality will be impaired. Most audio clips are recorded at . kilohertz, which is
suitable for listening while keeping the file at a manageable size for storage. WORD ALERT

Bit depth and bit rate is another aspect of digital audio. Bit depth is also known as sample resolution, Impaired: weakened or
and measures how many bits are used to record each sample. A recording with a resolution of  damaged.
bits will be lower quality than a recording with a resolution of  bits. The file will also be much larger
at the higher resolution. The bit rate marks how much data is processed for each second of sound
recorded and is formulated by multiplying the sample rate by the sample resolution.
ENRICHMENT
When both the sample rate and sample resolution are increased, so is the accuracy of the audio
recording. What is the lowest sample
resolution a sound file
could be recorded at
.. Image Representation before the listener would
detect a drop in quality?
By their very nature, images are visual; however,
these are also represented by binary numbers.        
In the simplest form, we can think of images as
DEFINITION
being a grid of pixels where a  is represented        
in white and a  is represented in black. Pixel: a tiny area of
The pixels are stored as a series of binary codes,         illumination on a display
and the number of pixels determines the screen.
resolution of an image. The greater the number        
of pixels, the higher the resolution and quality of
the image.        
REFLECT
Another factor of image representation is colour        
depth, which is the number of bits that are How many colours would
used to represent each colour. If two bits were be represented by 4-bit
        colour depth?
used per colour instead of just one, this would
allow twice the number of colours to be used        
in a picture. If -bit binary codes were used
to represent colours, there would be ,
possible colours. As the colour depth and
resolution increase, so do both the image size
and the image quality.

. Data Storage


Data in computers and computing devices require appropriate storage media. Each device uses
different types of storage media, with advantages and disadvantages.
One thing that is unique to all storage media is the measurement of its capacity. The capacity of the
storage medium is measured in bits.
• A bit can either be a  or a  in binary, and represents one binary decision.
• There are  bits in a nibble, and  bits or  nibbles in a byte.
• Typically, a byte would be the equivalent of one single character typed in a document.

Computer Systems 15

SB CS PP.indb 15 14.5.21. 14:13


Chapter 1
There are  bytes in a kibibyte. The reason that there are  bytes rather than  (decimal) is
because of the way that numbers are counted in binary. Binary numbers are counted using a system
of powers, and the next number in the sequence is always double the previous one.

          


Therefore, kilo is  to the power , equal to  times the value of . Kibi is  to the power of ,
equal to  times the value of .
This table sets out the units of measurement for storage devices in computing.

Unit of measurement Equal to


HELPFUL NOTES  bit The smallest unit of data storage
 nibble  bits
You may have heard
the terms kilobytes and  byte  bits
megabytes, rather than  kibibyte (KiB)  bytes
kibibytes and mebibytes.
Kilo and mega refer to
 mebibyte (MiB)  kibibytes
multiples of 1000, rather  gibibyte (GiB)  mebibytes
than 1024, and so it is  tebibyte (TiB)  gibibytes
more helpful to use the
terms in the table.  pebibyte (PiB)  tebibytes
 exbibyte (EiB)  pebibytes
 zebibyte (ZiB)  exbibytes
 yobibyte (YiB)  zebibytes

As of yet, there is no measurement of computer storage larger than yobibytes, mainly because
humans have not yet needed this. Each storage device is capable of supporting storage media up to
a certain number of bytes depending upon its type and usage.

.. Calculating the File Size of an Image File


It is important to know how the size of an image file is calculated for storage on a computer’s hard
disk. There are four steps:
. Multiply the number of horizontal pixels by the number of vertical pixels to obtain the total
number of pixels.
. Multiply the total number of pixels by the colour depth of the image to obtain the total number
of bits.
. Divide the total number of bits by  to get the file size in bytes.
. Divide the file size in bytes by  to get the file size in kibibytes.

Worked Example
The image here is to be stored on a computer’s hard disk.
To work out the total file size in kibibytes we can use the
following information:
• The number of horizontal pixels is  and the number
of vertical pixels is .
• The colour depth is  bits.
Therefore, the calculation of the file size is as follows:
 vertical pixels ×  horizontal pixels =  (total number of pixels)
 ×  (colour depth in bits) =  (total number of bits)
 ÷  =  bytes (file size in bytes)
 ÷  =  KiB (file size in kibibytes)

16 Computer Systems

SB CS PP.indb 16 14.5.21. 14:13


Chapter 1
.. Calculating the File Size of a Sound File
The size of a sound file can also be calculated by following several steps.
. Obtain the following data about the sound file:
• the sample rate (sometimes referred to as the frequency)
• the resolution (sometimes referred to as the bit depth)
• the number of audio channels that have been recorded (one channel is a mono recording,
and two channels is a stereo recording) WB LINK
. Multiply the sample rate by the resolution by the number of channels to calculate the bit rate, in
Consolidate your
bits per second.
understanding by
. Multiply the bits per second by the length of the sound recording in seconds, to calculate the completing Exercises
total number of bits. 1-3, pages 12-14 in the
. Divide the total number of bits by  to get the file size in bytes. Workbook.

. Divide the file size in bytes by  to get the file size in kibibytes.
. Divide the file size in kibibytes by  to get the file size in mebibytes.

Worked Example
The sound file below is to be stored on a computer’s hard disk, and we need to work out the
total file size in mebibytes.

We know the following information:


• the sample rate of this sound file is  samples per second (hertz)
• the resolution of the file is  bits per sample
• the number of channels used to make the recording is 
• the sound file is  seconds in length
Therefore, we can calculate the file size as follows:
 ×  ×  =  (the bit rate, in bits per second)
 ×  =  (total number of bits)
 ÷  =  bytes (file size in bytes)
 ÷  =  kib (file size in kibibytes – rounded)
 ÷  = . mib (file size in mebibytes – rounded)

Activity
 Calculate the file size in kibibytes of an image file that has  horizontal pixels and  vertical
pixels, and a colour depth of  bits.
 Calculate the file size of a sound file in mebibytes that has been recorded at a sample rate of
 samples per second, has a resolution of  bits per sample and has been recorded using
two audio channels. The sound file is  seconds in length.

Computer Systems 17

SB CS PP.indb 17 14.5.21. 14:13


Chapter 1

. Data Compression


As files and media become higher quality, the files we use increase in size. Computers only have a
finite amount of storage capacity, so some software applications can compress the files to store and
DEFINITION share them efficiently . Compression is a technique that reduces the size of a file. The benefits of this
are that files can be sent successfully across a network, which requires lower bandwidth and takes
Bandwidth: the less time to deliver, and the compressed files also take up less storage space.
transmission capacity of a
computer network. There are two types of data compression: lossless and lossy. Each method reduces the number of
bits in a file.

.. Lossless Compression


In lossless compression, file sizes are reduced but there is no loss of data. A simple example is
converting a text document to a portable document format (or PFD) file.
LINK WB
A process called run length encoding (RLE) is another method of lossless compression. This is where
Consolidate your a piece of compression software will look for runs of duplicated data and recode these runs as
understanding by smaller amounts of data.
completing Exercise 2, For example, if a run of notes for a sound file looked like this:
page 15 in the Workbook.
A A A B B B B B C C

it might be displayed as data like this:

         

RLE would look at the duplicates in a run, find the number of duplications and would reprogram
the line:

 (three s)  (five s)  (two s)


ENRICHMENT ABC
Can you find examples This way, none of the data is lost but the file is compressed by the software finding efficient savings
of different file types that of data where possible.
are created using lossless
compression?
.. Lossy Compression
As the name suggests, in lossy compression data is permanently removed from the file to reduce
the size.
Some ways the software can do this
include reducing the resolution or colour
depth of an image, or reducing the
WORD ALERT
sample rate or resolution of a sound file.
mp3: MPEG (Moving When a sound file is converted to an mp3
Picture Experts Group: the file this is an example of lossy sound. An
organisation that created mp file has had enough bits removed
the file type) Layer 3. to reduce the file size, but not enough
jpeg: Joint Photographic to change the sound of the sound file
Experts Group: the dramatically. This type of compression is
organisation that created perfect for storing many mp files on personal media-playing devices.
the file type.
Similarly, when an image is saved as a jpeg file, bits are removed so that the file looks lower in quality
but not enough so that the meaning is lost. Jpegs are often found on websites, as they tend to be
smaller in actual size and this allows the page to load faster.

18 Computer Systems

SB CS PP.indb 18 14.5.21. 14:13


Chapter 1

Let’s Map It

Computers display many


forms of information
This is represented
by binary code

• MAC addresses
• IP addresses
• Color codes

BINARY
Binary

DENARY
Denary Hexa-
decimal
HEXADECIMAL
POSITIVE +
We can convert between the NEGATIVE -

ADDITION Can lead to

MULTIPLICATION BINARY SHIFT

DIVISION

Text Sound Images File sizes can Storage


be calculated

ASCII
Unicode
Bits

Bytes
B I N A R Y

Kibi bytes

COMPRESSION
Files can be
reduced in size
Mebi bytes

Computer Systems 19

SB CS PP.indb 19
IGCSE_CS_TB_CHAPTER_1_with mindmap.indd 19 14.5.21.8:08
10/05/21 14:13
PM
Chapter 1

Let’s Review

 What are the differences between the binary, denary and hexadecimal number systems?
 What is the number  in binary?
 What is the number  in denary?
 In which direction should you read a binary number?
 Convert the denary number  to hexadecimal, using binary to help you.
 Convert the hexadecimal number D to denary, using binary to help you.
 Name three examples of the use of hexadecimal numbers in computing.
 Multiply the binary number  by  and show the binary result and its denary equivalent.
 Divide the binary number  by  and show the binary result and its denary equivalent.
 What is the name of the furthest-left bit in an -bit byte, used when multiplying?
 What happens to decimal numbers after a binary division is carried out?
 What is the name of the process used to convert a positive binary number into its negative
equivalent?
 What is the binary number that represents –?
 Find the binary number that represents –
 What is ASCII and how many characters are contained in the character set?
 Explain the difference between a kilobyte and a kibibyte.
 An image is  pixels horizontal and  pixels vertical. It has been created with a colour depth
of  bits. What is the file size of the image in kibibytes?
 What is the difference between lossless and lossy compression?

20 Computer Systems

SB CS PP.indb 20 14.5.21. 14:13


CHAPTER
Data
2 Transmission

COMPUTER SCIENCE WATCH

Scan the page to watch a clip on the types


of data transmission.
Before watching discuss what you expect
to see or hear.

QUESTIONS

• How is data transmitted between different


devices?
At the end of this chapter, you will be able to: • How do computers ensure that the data
understand that data is broken down into packets to be transmitted that is transmitted gets to its intended
destination correctly and accurately?
identify the structure of a data packet • Why is it important to keep data secure
describe the process of packet switching when sending it to another device across
a network?
define how data is transmitted from one device to another, using
different methods of transmission
understand what the USB interface is and how it is used to transmit data
understand that data needs to be checked for errors and the different
methods used to do this
explain why data is encrypted and how this is done

21

SB CS PP.indb 21 14.5.21. 14:13


Chapter 2
Data transmission is a vital part of electronic communication. In order for computers and humans to
communicate with one another, it is important to understand how that communication data makes
QUICK CHECK its way around a network, transfers from one device to another and how systems ensure that errors
are detected and corrected. It is also important to learn how encryption keeps data safe and secure
How are computers during the transmission process.
connected together?
How does the
internet work?
. Types and Methods of Data
Transmission
When data is generated by a computer from information provided by human input, it is often
ENRICHMENT necessary for that data to be transmitted either to another device connected directly to a computer,
or across a network such as the internet to a device elsewhere in the world.
The origins of data In order for this transmission to occur, data has to be first broken down into packets ready for
packets can be traced sending. A packet is a small chunk of data and, when these are sent across a network, the chunks
back to the 1800s when have to be put back together again to formulate the original data that was intended to be received.
Samuel Morse sent the
first telegraphic message
and invented what is
known as Morse Code,
.. Packet Structure
a series of dots and A packet of data contains the following pieces of information:
dashes that needed to be
translated into letters
Item Description
and words.
Packet header This is added to the data prior to sending the packet and contains both
the Internet Protocol (IP) address of the computer that is receiving
the packet, and also the IP address of the computer sending it (the
originator).
DEFINITION
The packet header also adds two identification numbers to the data:
Internet Protocol (IP) the number of packets that the data has been broken down into, and
address: a unique string the packet number. This is used for ‘rebuilding’ the data at the end of
of numbers separated by transmission.
full stops that identifies
Payload This is the bundle of data that is contained within the packet.
each computer using the
protocol to communicate Trailer Each packet has a trailer which is sometimes known as a footer. It contains
over a network. bits of data that tells the receiving device when it has reached the end of
Originator: the sending the packet transmission. This is what is known as a validation check, and
device. the trailer ensures that the data that left one computer matches the data
that has arrived at the other computer. If the check does not match, the
packet will be requested again from the originator.

Once data is ready for transmission, it will be broken down into as many packets as are required
to send it by the originator and will then be sent across the network or the internet.

.. Packet Switching


The packets do not travel along cables in the same order that they were created and will often
take different routes across a network to get to their intended destination. This process is called
‘packet switching’ and it means that data can be transmitted by the most suitable route to get to its
intended destination. The routes that are taken by packets are determined by the router, a device
that directs incoming and outgoing traffic on a network.

22 Data Transmission

SB CS PP.indb 22 14.5.21. 14:13


Chapter 2

Data being sent along network cables.

As the packets arrive at the destination device, they may arrive out of order. This is where the bits of
data that make up the packet header and the trailer become important, as the receiving device will
wait until all packets have arrived.
Once the packets have all arrived at the destination and the last packet is received, the device will WORD ALERT
reorder them into the correct order so that the computer can read the data that it has obtained.
Finally, the trailer is checked for parity with the originating device and, if the data matches, the Parity: ensuring that
transmission process is complete. As with all computing processes, data transmission and packet something is the same.
switching occurs extremely quickly, in a matter of seconds.

.. Methods of Data Transmission


There are several different methods of transmitting data depending on the type of hardware and
connections being used. This is usually a key decision when it comes to buying a new computer, as a HELPFUL NOTES
user will want to know how fast data can be transmitted between devices.
It is important to read
The amount of data that can be transmitted at a given time is called bandwidth. The higher amount the small print carefully
of bandwidth available, the quicker the transmission speed. when purchasing a new
The types of transmission that devices can use to perform data transfer are: computer to see what
• Serial connection ports it
has – this can make a big
• Parallel difference to your work
• Simplex efficiency.
• Half-Duplex
• Full-Duplex

Serial Data Transmission


Computer Computer

Bits
Figure . Serial transmission. (Single)

Data Transmission 23

SB CS PP.indb 23 14.5.21. 14:13


Chapter 2
This type of data transmission occurs when a computer or device is connected to another computer
or device using a single data channel. Data is transmitted one bit at a time, sequentially, down
ENRICHMENT the channel.
An example of this type of data transmission occurs when a computer is connected directly to a modem.
Can you find out when
serial and parallel ports One of the advantages of using a serial transmission method is that it is very reliable for transferring
were no longer included data over longer distances, although sometimes it is not the most practical. There are also much
in computers? What fewer errors in serial transmission, as bits are sent one at a time, and only one single channel is
replaced them and why? required to achieve this transmission. Thus, this is a lower cost method of transmitting data.
The disadvantage of a serial transmission is that transmission speeds can be slow as only one
channel is being used to transfer data.

Parallel Data Transmission

Computer Printer
Bits
Figure . Parallel transmission. (Multiple)

REFLECT Parallel data transmission is where multiple bits of data are sent at the same time along different
channels in the same cabling.
Most modern printers
now are connected to An example of this type of data transmission is where a computer is connected directly to a printer.
computers using network The advantages of this type of transmission is that faster data transmission takes place because of the
cables and data is multiple channels being used. The disadvantages are that this type of transmission is more expensive
transmitted much faster
and synchronisation errors can occur due to the separation of data across different channels.
this way.

Simplex Data Transmission


Input

Computer

Unidirectional

Figure . Simplex transmission.


QUICK CHECK
Simplex transmission is a one-directional (or unidirectional) mode of data transmission. The data will
What other devices only go one way, and the receiver of the data does not send any data back to the sender.
can you think of that An example of this type of transmission occurs between a keyboard and a monitor. The keyboard
use unidirectional data
sends input data to be displayed on a monitor, but the monitor does not send any data back to the
transmission?
keyboard.
The advantage of simplex transmission is that the process can use the full bandwidth of the
channel. The disadvantage of this transmission type is that it is not possible to engage in two-way
transmission using this method, and most forms of communication rely on this to be successful.

24 Data Transmission

SB CS PP.indb 24 14.5.21. 14:13


Chapter 2
Half-Duplex Data Transmission

Transmission
Not simultaneous

Figure . Half-duplex data transmission.

In half-duplex transmission, two-way communication is possible because both devices can send and WORD ALERT
receive data packets. With half-duplex transmission, although the direction of the data flow can be
reversed, transmission cannot be sent in both directions simultaneously. Simultaneously: at the
same time.
As with simplex transmission, the full
bandwidth of the channel is used, but only in
a single direction at any one time.
An example of half-duplex data transmission ENRICHMENT
is in the use of a walkie-talkie handheld
communication device. When one device Why would half-duplex
data transmission not be
sends data, the other device is unable to do
an appropriate method
so until the transmission has completed. of data transmission for a
One advantage of this type of transmission video phone call?
is that it enables two-way transmission
using full bandwidth, which is important
for communication, representing an
improvement on simplex transmission. The
disadvantage of half-duplex is that there
are delays in the transmission process due
to the need to wait to be able to use the
bandwidth.
Walkie talkies.

Full-Duplex Data Transmission

WB LINK

Consolidate your
Bi-Directional understanding by
completing Exercises
1-3, pages 17-21 in the
Workbook.

Figure . Full-duplex data transmission.

This method of data transmission is bi-directional, and data can flow simultaneously to and from
sender to receiver simultaneously. Full-duplex transmission is made up of two simplex channels,
one flowing in one direction, and the other flowing in the opposite direction. It is the fastest
method of transmitting data.
An example of full-duplex transmission is a telephone network, where users can talk and listen at
the same time.

Data Transmission 25

SB CS PP.indb 25 14.5.21. 14:13


Chapter 2
The advantages of using full-duplex
transmission are that it is the fastest
method of data transmission due to each
communication using its own simplex
channel, and there are no delays in
receiving data. The disadvantage of using
full-duplex is that some networks are
not capable of utilising the technology,
especially if older equipment is being used,
and the technology is only as good as its
oldest devices.

.. Universal Serial A telephone call is bi-directional.

Bus (USB)
HELPFUL NOTES The Universal Serial Bus (USB) is a type of communication
port that has been built into computers in order to do away
USB technology was first with other older forms of port. As discussed earlier in the
designed and created in chapter, serial and parallel transmission of data were the
the 1990s by Ajay Bhatt industry standard for sending and receiving bits of data to
from the IBM Corporation and from devices such as printers, keyboards and mice, and
and has now become the this meant that computers had to be manufactured with
standard technology for several of these ports built into them.
plug and play devices in The USB logo.
modern computing. The USB port was designed to be a much more versatile
port and, soon after it was designed, computing manufacturers began designing devices that had
USB connectors as a standard. USB connectors come in a variety of types, with Type-A (rectangular)
and Type-B (square with slanted corners) being the most popular type at first, being joined more
LINK recently by Micro-USB and Type-C connectors. Type-C are now the standard for many types of
WB
mobile devices and laptops, due to their ability to supply power as well as transmit data.
Consolidate your USB cables contain two wires for power
understanding by supply purposes and two wires for data
completing Exercise 4, transmission. They are designed to be able
page 22 in the Workbook.
to supply power and transmit data across
a variety of different devices. Due to their
inter-operability, USB is now the connection
of choice for manufacturers, and devices
REFLECT
such as keyboards, mice, hard disk drives,
headphones, mobile phones, tablets and
How many different
devices do you own that laptops all use the technology.
uses a USB connection? Different devices have different numbers and
types of USB ports depending on their usage,
and many mobile phones just have one USB
port that is used for both charging the device
and transferring data to other devices.
WORD ALERT The advantages of USB are that they are so
ubiquitous, and there are millions of devices
Ubiquitous: located that have been produced that use the
everywhere. technology in some form. The technology
is very easy to use as the connectors plug in
simply. The ability to supply power as well as USB connectors and their ports.
data means that external power sources are
not needed for devices, keeping costs lower.

26 Data Transmission

SB CS PP.indb 26 14.5.21. 14:13


Chapter 2
The disadvantages of USB are that data transmission speeds are still relatively low compared with other
types of transmission (although it is increasing all of the time as the technology develops). Also, the
length of cable can have an effect on the transmission quality, therefore it should not exceed  metres.

. Methods of Error Detection


Despite all of the technology that is
evolving when it comes to data transmission,
sometimes errors can occur in the transfer
of data from sender to receiver. When data DEFINITION
is changed or altered in transmission, it is
known as corruption, and it is usually due to Corruption: where
something is altered or
interference with the data during the process
changed without a user
of transmission. It is therefore important for
knowing.
computers to be able to detect these errors.
Parity check: is a bit added
There are several methods that are built into to a string of binary code
computer processes for error detection, including as the simplest form of
the parity check, checksum, echo check and error detecting code.
automatic repeat requests. There are also methods Data transmission errors can lead to problems and
for checking errors in data entry. need to be detected and stopped.

.. Parity Check WORD ALERT

This type of error checking first requires a protocol to be agreed upon between the sender device Protocol: a set of rules
and receiver device. A protocol is a set of rules that both devices will follow. When parity check is that are applied to the
used as the method of error detection, the protocol can either be even or odd parity. transfer of data.

Whichever type of protocol is used, a parity check involves adding an additional binary bit (a  or a )
to the end of a -bit byte to ensure that the number of  bits is either even or odd.

Computer Computer

10110011 1 10110011 1

Parity bit Parity bit


Even

Parity check passed

Computer Computer

10110011 1 10110011 0

Parity bit Parity bit


Even

Parity check failed

Retry
Figure . No Parity check.

Once the protocol of parity has been agreed, the sender then adds either an extra  or extra  to the
end of the code. The byte is then sent, with the parity bit attached to the receiver. Once the data
has been received, the receiving device will check that the number of  bits is correct according to
the agreed protocol (odd or even). As long as this is the case, then the data transmission has been
successful. If the parity does not match the agreed protocol, the receiving device will ask for the data
to be re-transmitted.

Data Transmission 27

SB CS PP.indb 27 14.5.21. 14:13


Chapter 2
It is also important to note that a parity check will not always detect an error, if the number of s in
the received byte adds up to the correct parity. It is also important to recognise that the examples
discussed here are in relation to single bytes; when data is transmitted, it is often many multiples of
bytes that are sent. In this instance, the same process occurs, however the parity is calculated either
using a parity byte attached to a set of bytes, or using a parity block, which is a symbol added to the
end of a block of code.

.. Checksum
ENRICHMENT
This method again requires an agreed protocol to be determined prior to the data transfer, this time
The arithmetic that is involving a mathematical calculation or sum.
carried out in checksum An algorithm is used to calculate a checksum value from the data that will be transmitted, and then the
is usually an algorithm of block of data is transmitted along with the checksum that has been calculated using this method.
some description.
The receiving device will then re-use the algorithm based on the data it has received, and will compare
the two checksum values. If the values match, then the data transmission has been successful. If the
checksum values do not match, the receiving device will ask for the data to be re-transmitted.

.. Echo Check


This is a different type of error check, in that there is no agreed protocol prior to transmission. In an
echo check, the receiving device will immediately send a copy of the data back to the sender and
a comparison is carried out. If there is any difference between the two sets of data during the echo
check, the data will be re-transmitted.

.. Automatic Repeat Requests (ARQ)


HELPFUL NOTES
This form of error checking uses the concept of time to ensure successful transmission of data.
An ARQ is based upon
When a sending device sends a block of data, the computer will wait for a positive or negative
repetition, and this acknowledgement from the receiving device.
repetition will occur A positive acknowledgement will be a recognition that the receipt of the data has been
as often as needed successful, and a negative acknowledgment will indicate that data has not been received.
before the data is sent If a positive acknowledgement is received, the ARQ will stop sending the data, but, if a negative
successfully. acknowledgement is received, the ARQ will continue sending the data until a positive receipt
is notified.
The ARQ check also recognises that timeouts may occur, in that no acknowledgement is received at
all. In this case, after a set period of time waiting, the data will be sent again, and this will continue
until an acknowledgement comes back to the sender.

.. Check Digits


DEFINITION
The error detection systems described above help to
spot errors during the transmission of data between two
Barcode: a machine-
different devices. Sometimes, data discrepancies can
readable code in the
form of numbers and a occur due to human input errors.
pattern of parallel lines of The check digit is an error check that is designed to spot
varying widths, printed these human errors and is a final number that is added to
on a physical item. This the end of a numerical code. Check digits can be found
pattern identifies it from on barcodes and ISBN numbers on the back of books.
other barcodes.
It is a digit that is calculated using all of the other digits
ISBN number: International in the code and, depending on the product, there will be
Standard Book Number, a particular mathematical calculation that will be carried A barcode found on products in shops.
a global system for
out on the code to generate the check digit.
identifying individual
books. ISBN numbers If the check digit does not match the expected result, then it may be that the barcode has been
have 13 digits. mis-read or that a human error has occurred. This would then mean that the item code has to be
rechecked to ensure that it is correctly listed and priced.

28 Data Transmission

SB CS PP.indb 28 14.5.21. 14:13


Chapter 2
Worked Example
A barcode is created for a new toy on the market. The barcode number is as follows:
  5
ENRICHMENT
The check digit in this barcode is the number 5, this is highlighted in red above.
This has been generated by carrying out the following mathematical calculation: Check digits are often
found at the end of
Step : Add Digit  to Digit  numerical codes, such as
Step : Divide by Digit  on a barcode. Can you
find the check digit on the
Step : Add Digit  barcode for this book?

(+

+= )
The computer in the toy store will know this calculation and so, when the barcode is scanned,
the check digit will be read to make sure it matches the expected result.

. Encryption
As we rely ever more on communication and transmission of data across networks like the internet,
it is so important to ensure that these transmissions are as secure as possible. Insecure transmission
of data can lead to potentially harmful situations and leave your data vulnerable to hacking or
interception. REFLECT
A way of keeping data safe and secure during transmission is to use a method of protection called
It is possible to make your
encryption. own Caesar cipher code
The origins of encryption can be traced back to Julius Caesar, in Roman times, who came up with the wheel to enable different
fairly simple idea of changing messages by moving the alphabet forwards or backwards a number of forms of encryption
steps. This is called the Caesar cipher. You would first number the alphabet from  to  starting with protocol to be used.
the letter ‘a’ and numbering all the way to ‘z’.
Once you have done this, you can then decide on an encryption protocol such as −, meaning that
you move the alphabet backwards two steps, as per the table below: QUICK CHECK

What types of information


Text A B C D E F G H I J K L M N O P Q R S T U V W X Y Z do you think you might
share when buying an
Cipher C D E F G H I J K L M N O P Q R S T U V W X Y Z A B item online?

Therefore, a message such as “HELLO WORLD” would become “JGNNQ YQTNF”. As long as both parties
know the protocol, messages can be deciphered.
Data can contain private or sensitive information, for example, users’ personal information from their
online bank accounts, or payment card details when purchasing an item from a website. When these
packets of data are transmitted across a network, it is vital that this information remains private and
secure to prevent criminals from accessing potentially sensitive information.
When using websites such as online
banking or making online purchases, WORD ALERT
you will notice that, when completing a
transaction, the protocol changes from just Transaction: the process
hypertext transfer protocol (http) to secure of buying or selling
hypertext transfer protocol (https). This can something.
be noticed by looking at the address bar of
the browser being used to access the
web page.

Data Transmission 29

SB CS PP.indb 29 14.5.21. 14:13


Chapter 2
Secure http ensures that a secure connection is made between the two devices engaging in the
transfer of data. The data packets are encrypted before they are transmitted across the network and
WORD ALERT are decrypted only when they reach their intended destination. This ensures that criminals such
as hackers would be unable to access the private and confidential information as they would be
Decipher: converting unable to decipher the encryption. Any data that was intercepted during this process would be
code into normal meaningless to the hacker.
language.
The process of encryption requires the devices at either end of the transfer to use an encryption
key to unscramble the secure data. Websites built with encryption technology will give users the
confidence to carry out these transactions.
There are two types of encryption that use keys to scramble and unscramble data: symmetric and
asymmetric encryption.

HELPFUL NOTES .. Symmetric Encryption


This is the simplest type of data encryption, and involves the
When dealing with the
encryption of computer sender and receiver of data having a secret key that is used to
data, unencrypted data cipher and decipher the data.
is referred to as ‘plaintext’ A symmetric secret key is usually a string of numbers, a word
and encrypted data is or random letters that is merged with the text of a message
referred to as ‘ciphertext’. to change the data. As both the sender and receiver know
what the key is, it can be easily removed from the message,
leaving the actual text in its place.
The problem with symmetric encryption is that the key has
to be known and shared by both sender and receiver prior to
transmission, meaning that it could potentially be intercepted
and become insecure.
A better and newer method of encryption would be asymmetric
encryption.
Encryption requires the use

LINK WB
.. Asymmetric Encryption of keys.

Consolidate your This type of encryption is also what is called ‘public key encryption’. This type of encryption uses two
understanding by different keys to cipher and decipher a message. It is more secure than symmetric encryption which
completing the Exercises only uses one key.
from pages 23-25 in the When a message is ciphered ready for transmission by a sender, the receiver will generate a pair of
Workbook. keys: a public key and a private key. The public key is shared with any device that might wish to send
a message to the receiver.
The sender will then use the receiver’s public key to encrypt the message ready for sending.
However, the public key cannot be used to decipher the message. When the receiving device
obtains the message, it then has to use the private key to decipher the message and since this is
never shared, it is a more secure process compared to asymmetric encryption.

Activity
1 You wish to send the following message to your friend:
MEET ME AT THE SHOP ON SATURDAY MORNING
Come up with a cipher key protocol to encrypt this message, encrypt it and ask your friend to
decrypt it using your protocol. Once you have tried this, send a message of your own, using a
different encryption protocol.
2 How would you encrypt and decipher numbers and punctuation codes, such as
question marks?

30 Data Transmission

SB CS PP.indb 30 14.5.21. 14:13


Chapter 2

Data Transmission 31

SB CS PP.indb 31 14.5.21. 14:13


Chapter 2

Let’s Review

1 What is a data packet?


2 Inside a data packet there are three components, what are they called?
3 What is the job of the trailer in a data packet?
4 What does packet switching mean?
5 What is the difference between serial and parallel data transmission?
6 Explain the link between simplex and full-duplex transmission.
7 Why is half-duplex transmission not used in telephone communication?
8 What do the initials USB mean?
9 Name three devices that have USB connections.
10 What are two ways that data could be changed during transmission?
11 What are the two types of parity checks?
12 True or false: a echo check is where data is checked only by the receiving device.
13 What is the purpose of a check digit in a barcode?
14 Explain a timeout when an automatic repeat request occurs.
15 True or false: asymmetric encryption uses just one key when ciphering and deciphering data.
16 Why is encryption important when transmitting data?

32 Data Transmission

SB CS PP.indb 32 14.5.21. 14:13


CHAPTER
Hardware
3
COMPUTER SCIENCE WATCH

Scan the page to watch a clip on CPUs


and the main characteristics of the Von
Neumann model.
Before watching discuss what you expect
to see or hear.

QUESTIONS

• How does the CPU control the internal and


external hardware?
At the end of this chapter, you will be able to: • What does computer architecture look like?
• understand that a microprocessor is a type of integrated circuit on a • How do the input, output and storage
single chip devices link together in a computer?

• define the role of the central processing unit (CPU) in a computer


• identify how each component in the CPU operates to create the fetch-
decode-execute cycle
• explain what can affect the performance of a CPU
• define what is meant by an instruction set
• understand that an embedded system is used to perform a dedicated
function in a range of different systems
• identify a range of different input and output devices
• explain what a sensor is used for, including the type of data they capture
• identify that there are two types of storage: primary and secondary
storage
• understand how virtual memory is created and used
• define what cloud storage is and what the advantages and
disadvantages are
• identify the components required to connect a computer to a
network, including the role of each component
• understand what is meant by a media access control (MAC) address
and an internet protocol (IP) address and how they are used

33

SB CS PP.indb 33 14.5.21. 14:13


Chapter 3

. Computer Architecture


A computer device is made up of a range of components, both internal and external. All the
DEFINITION
components have important roles in the successful operation of the device. Whether it is a desktop
Architecture: how a computer, a laptop, a tablet or a smartphone, the basic principles of the architecture are the same.
computer system is An important part of this architecture is the rules and methods the components follow. Figure .
designed, including the maps out these principles.
rules and methods that
the system should follow.

INPUT PROCESS OUTPUTS

STORAGE

Figure . A basic computer architecture diagram.

All computing devices are based upon the straightforward premise that items of processing
HELPFUL NOTES hardware require some input of information. This information is converted into data that the
processor can carry out calculations with and turns the information into instructions. Some of this
In computing terms, data may need to be stored and recalled, and the computer will then produce an output depending
instructions and on the instructions and data that has been processed.
information tend to be
qualitative and data is
quantitative (numerical).
.. The Central Processing Unit (CPU)
At the heart of every computer system sits a processor chip.
This central processing unit (CPU) is crucial to the
operation of a computer system, and it is the job
of this device to process the instructions and
data entered through the input devices.
The CPU then uses the data to perform
various operations and ultimately
WORD ALERT produces an output. The CPU is
also known as a microprocessor,
Intricate: very which is an intricate set of
complicated or detailed. circuits contained on a chip.
These circuits are microscopic
in size so can be built into a
variety of devices.

The central
processing unit.

34 Hardware

SB CS PP.indb 34 14.5.21. 14:13


Chapter 3
.. von Neumann Architecture
In the s, computer scientist and mathematician John von Neumann further developed the ENRICHMENT
computer architecture principles shown in Figure .. He established a design still used in the
development and manufacture of computer systems today – to work effectively, computer systems What other developments
need a method of storing programs while they are running. was John von Neumann
responsible for?

Central processing unit


Control unit
Input Arithmetic / Logic unit
device
Registers PC CIR
Output
device
AC MAR MDR

Memory unit REFLECT

Figure . von Neumann architecture. Can you draw the flow
of data between the
This type of architecture is used as the starting point for most computer devices. Von Neumann different components of
discussed how the CPU requires input and produces output, and that the microprocessor the CPU?
contains several different components: a control unit, an arithmetic logic unit and a set of smaller
components called registers. The architecture also includes a memory unit with instructions and
data, both read from and written to. This acts as a storage bank for instructions that are used LINK
regularly by the CPU while the computer is powered, and is called random access memory (RAM)
(see section ..). Finally, buses or connections carry the data from one component of the CPU to See section 3.1.7 The
another, as shown by the arrows in Figure .. Memory Unit.

.. The Control Unit (CU)


The control unit is the part of the CPU that controls all of the input and output devices as well as the
arithmetic logic unit (ALU) (see below) and the memory unit. The CU is responsible for making sure
all these components follow the instructions it has processed from the input.

.. The Arithmetic Logic Unit (ALU)


As the name suggests, the arithmetic logic unit enables the processor to carry out mathematical LINK
operations on data, such as adding and subtracting, and logical operations, such as AND, OR and
See Chapter 10 Logic
NOT. This is important in respect of processing data, which is numerical digits in its most basic form.
Gates and Circuits.

.. Registers
There are five different registers contained within a CPU, all of which are data storage areas.
Before data can be processed it must be stored in one of these.

The Memory Address Register The Memory Data Register The Accumulator
(MAR) (MAR) (ACC)

Program Counter The Current Instruction Register


(PC) (CIR)

Hardware 35

SB CS PP.indb 35 14.5.21. 14:13


Chapter 3
• The memory address register (MAR) is responsible for remembering the memory location of
data that the processor needs to access.
• The memory data register (MDR) holds data that is being transferred either to or from the
REFLECT
memory unit.
• The accumulator (ACC) stores mathematical or logical results of processing that has been carried out.
What is the fastest current • The program counter (PC) contains the address or location of the next instruction to be carried
speed of processor fitted out by the CPU.
to computer hardware? • The current instruction register (CIR) contains the instruction that is being carried out at the
How can you find a current time.
computer’s specification
and the processing The processing of instructions and data by these components is carried out extremely quickly, and
speed? this processing speed depends on the specification of the processor installed inside the computer.

.. Buses
Several buses, otherwise known as connections, carry data around a computer. Of these, there are
three specific buses that the CPU uses to transfer information between the control and arithmetic
logic units and the memory unit:

The address bus The data bus The control bus

• The address bus carries the address (or


location) but not the data between the memory
unit and the CPU.
• The data bus carries data between the
processor and memory units and the input and
output devices connected to the computer.
• The control bus carries instructions from the
CPU to control the actions of the computer.

.. The Memory Unit


The memory unit of the CPU stores instructions
and processes that the computer needs regularly Computer bus cables.
while processing data. This is a much faster way
for the CPU to obtain these instructions than
retrieving them from a storage device like a hard
disk. This unit is a component called random
access memory (RAM), so named because the Random access
CPU can directly access any part of the memory. memory.
RAM is a type of volatile memory, in that it does
not retain its contents when the computer
is powered off. The unit is made up of small
microchips, each with its own address, which is
important for speed of access.

Activity
Can you draw a flowchart to represent the order that data flows from the input devices, around
the components of the CPU and to the output devices?

36 Hardware

SB CS PP.indb 36 14.5.21. 14:13


Chapter 3

. The Fetch-Decode-Execute Cycle


WB LINK
Arthmetic Registers
Logic Unit Program Counter Consolidate your
Memory Address Register understanding by
Memory Data Register completing Exercises
Current Instruction Register 1-2, pages 27-30 in the
Accumulator Workbook.
Address Address
 LOAD 
 SUBSTRACT 
 STORE  Key
 

Input  
Address Bus
Devices 
 Data Bus
 
Random Access Control Bus
Memory (RAM)

Figure . Fetch-decode-execute cycle illustrated.

All modern computers with architecture based upon the work of John von Neumann use a method
of processing data known as the fetch-decode-execute cycle. This cycle happens in a matter of
milliseconds and enables a computer to logically process the data it receives in the correct order for
the user’s requirements.
All the component parts of the central processing unit (CPU) are used to make the cycle work. The WORD ALERT
cycle begins with an instruction given by a user via an input device and is sent to the control unit
(CU) via the control bus. The CU then moves the appropriate processing instructions into the RAM. Control bus: a bus that
 The program counter stores the address location of the next instruction to be carried out. This carries instructions from
the CPU to control the
location number is copied into the memory address register (MAR).
actions of the computer.
 The program counter is incremented or increased by one and this register now stores the next
instruction to be processed.
 The control unit (CU) makes a request to the RAM for the instruction and obtains the address of
the instruction from the MAR by sending a signal along the address bus.
 The data that is being held in the RAM in the correct address is carried along the data bus to the
memory data register (MDR).
 Once the instruction arrives at the MDR, it is copied into the current instruction register (CIR).
 The instruction is then decoded in the CIR using the arithmetic logic unit (ALU) and then
carried out. The result of this processing is stored in the accumulator (ACC).
The cycle then begins again.
Once all the necessary instructions have been decoded and executed within the CPU, the CU then
sends the results of the processing to the output devices using the control bus.

. Cores, Cache Memory and Clock Speed


Other components make up part of the CPU and can make a significant difference to the overall
operating speed of a computer. While the CPU processes instructions and data extremely quickly,
other factors can affect a computer’s performance.

Hardware 37

SB CS PP.indb 37 14.5.21. 14:13


Chapter 3
.. CPU Cores
REFLECT
In traditional computer architecture, there would
What is the highest be one CU, one ALU and one set of registers that
number of cores that comprise the CPU. This would be known as a
a computer has been processing core. Computers are now available that
manufactured with? are dual-core and quad-core, with eight cores or more
also possible within one system.
With a dual-core processor a computer has two CUs,
two ALUs and two sets of registers, enabling it to
fetch, decode and execute twice as many instructions,
simultaneously. More cores mean more processing
power and a higher capability compared to a system
with a single processor core. Each core can perform
the fetch-decode-execute cycle independently.

LINK WB
.. Cache A CPU core.

Consolidate your
Modern CPU chips have a small amount of RAM built in, called a cache memory. This is different
understanding by
completing Exercise 3,
from a computer’s main memory and is used where a processor has instructions and data it needs
page 31 in the Workbook. regularly. These are stored in the cache for quicker access, rather than fetching the instructions and
data from the main RAM each time they are required.
The bigger the cache memory, the less time it takes for the processor to fetch the instructions and
data it needs most often.

.. Clock Speed


ENRICHMENT
Clock speed is an important measure in terms of CPU performance capabilities. This refers to
What is meant by the number of electrical pulses that the clock inside the CPU can produce every second. This
‘overclocking’ a processor? measurement is made in hertz, and modern clock speeds are usually measured in gigahertz. One
gigahertz equals one billion electrical pulses per second.
The higher gigahertz that a processor is clocked at, the more fetch-decode-execute cycles can be
carried out by the CPU.

. Instruction Sets


A set of common instructions have been developed by processor manufacturers so that CPUs
operate as efficiently as possible. This instruction set is all the commands that can be processed by a
CPU. The instructions are the most basic types of command a computer can respond to and execute,
and these are referred to as operations. These operations ensure that the control unit and arithmetic
logic unit can carry out their respective jobs easily.
Operations are made up of opcodes and operands. Opcodes are used to perform an action on an
operand. We refer to coding such as this as machine code.

.. Opcodes
In straightforward terms, an opcode, short for operation code, gives the CPU a precise job that is
required to happen, and the opcode then needs a piece of data to carry out this job on. Opcodes
can either tell the components an operation to carry out or can instruct one of the units to do
something to a particular piece of data. An example of an opcode would be ‘ADD’, ‘DIV’ or ‘GOTO’.
The opcodes are stored on a computer’s hard disk and would usually be copied into the main RAM
when the computer is powered on. The most regularly used opcodes would then be moved from
the RAM to the cache memory.
38 Hardware

SB CS PP.indb 38 14.5.21. 14:13


Chapter 3
.. Operands
An operand is the data that is required for the specific job as detailed by the opcode. The operand
may be a piece of data itself, or it may be an address location within the main RAM or a register.

Examples of opcodes and operands


• ADD  (where  may be a number to add to a different piece of data held for processing)
• DIV , (where  and  may refer to address locations)
• GOTO  (where  may refer to an address location)

Activity
Make a list of five additional opcodes that a computer uses and write down a definition of what
each opcode does.

. Embedded Systems


When discussing processors and computer systems, we have traditionally tended to think
about desktop and laptop computers. These are referred to as general purpose computers, capable
of performing a wide range of different activities. However, there are other types of computer
system that carry out rather more specific tasks and jobs. An example of this is known as an
embedded system.
With an embedded system a larger device uses a small built-in computer to carry out its
functions in a more effective way. The computer system usually has a very specific job, and only
carries out that job when required.

Embedded systems in the home Embedded systems outside the home

Dishwashers Vending machines


GPS and satellite navigation Lighting systems
A GPS device is
Central heating systems Closed circuit television (security) an example of an
Calculators embedded system.

One of the key features that sets an embedded system apart from a general-purpose system is that
the user is simply a user rather than having an influence over the programming of the device. On
a laptop, for instance, a user can upgrade the operating system of the computer, but on a satellite
navigation device they have to plug the device into a computer and let it update automatically or
send the device away to the manufacturer for an update.
Embedded systems tend to be low power devices due to their limited nature and capabilities. This
does mean that they can be quite compact (for example a watch), and they can also be operated
using a battery for power (such as a calculator).

Activity
Think of three devices in your house that you would classify as an embedded system? For each
device, describe the information and data that it processes, and how a user might interact with
the device.

Hardware 39

SB CS PP.indb 39 14.5.21. 14:13


Chapter 3

. Input Devices


A variety of input and output devices are used to control and interact successfully with computer
software.
An input device is a piece of hardware that a human uses to give commands to and interact with the
computer, and provide data for the computer to use. This data is then processed by the computer to
produce an output.

Keyboard
• A keyboard is one of the most
important input devices used to
give data and instructions to a
computer.
• It has a selection of keys that all
perform different tasks.
• Its main role is for the entering
DEFINITION and typing of letters and numbers.
• A keyboard also has arrow keys
Universal serial bus (USB): for movement, control keys that
a standard connector perform standard input tasks and
found on many different function keys that perform more
types of computer and specific tasks. A standard computer keyboard.
used to connect external • Larger keyboards have a numeric
devices.
keypad (see below), which is useful for financial or accounting purposes.
Bluetooth: a form of
• Laptop keyboards tend to be more compact with essential keys only. This means the keyboard is
wireless connection
lighter and smaller.
for connecting devices
together when they are • The keyboard is connected to the computer using either a universal serial bus (USB) port or
near each other. wirelessly using a Bluetooth connection.
• Tablets and smart phones have electronic touch keypads instead of a physical keyboard.

Numeric Keypad
REFLECT A numeric keypad is a small
numbered pad of keys or buttons
The QWERTY keyboard labelled from  to . It is often
is the standard one used found on a standard computer
in computers around the keyboard but not usually on
world. It is named after smaller laptops.
the order of the first six
letters. Can you find out Numeric keyboards are also often
about different types of located beside locked doors or
keyboard layout? control boxes for alarm systems
and are used to gain access to a
building or a room.
While they are useful for entering
numerical data quickly, this keypad
often has a single purpose, such as
entering a keycode. The buttons
or keys also tend to be much
smaller than keys on a computer
keyboard.
A numeric keypad.

40 Hardware

SB CS PP.indb 40 14.5.21. 14:13


Chapter 3
Pointing Devices – Mouse
A mouse is a standard pointing
device, usually packaged with a
computer alongside a keyboard but
also available to buy separately. A
mouse typically has two buttons –
for left and right clicks – and often
has a jog wheel in between the
buttons for easy scrolling.
This device is connected to a
computer using either a USB port
or wirelessly with a Bluetooth
connection.
A mouse is used with operating A standard computer mouse.
systems and other software for DEFINITION
giving point and click instructions to the computer and for more complicated processes such as
selection and dragging. It works by shining optical light onto a flat surface, which is translated into Operating system: a
piece of software that
directional movements of the onscreen pointer.
communicates with the
hardware and allows
Other Pointing Devices other programs to run.
There are several other pointing devices that operate in a similar way to a mouse.
• Touchpads are pointing devices installed within a laptop for convenience and portability.
• Trackballs are used to point and move in any direction and allow greater accuracy in precision WORD ALERT
movements.
• Stylus pens are used with tablets to input graphical information and for digital drawing. Stylus: a pen that can
• Gaming controllers are bespoke pointing devices for interacting with gaming scenarios on a be used either directly
games console. onto a screen or a pad
connected to a computer.

ENRICHMENT

Can you find other types


of device that act as a
point and click input?
Think about computer-
based devices in your
home – how do you
control them?

A selection of pointing input devices.

Hardware 41

SB CS PP.indb 41 14.5.21. 14:13


Chapter 3
Real world examples where these pointing devices are found include:
• a trackball on medical equipment
• a stylus pen used for graphic design
• a gaming controller used with a console

Touchpads, trackballs and


gaming control devices.

Touch Screens
A touch screen is made of glass and reacts to a finger
press. They usually have a built-in menu. Once the user
has made a selection with a finger press, the screen
reacts by displaying a different screen or drop-down
menu. The touch screen works with simple decisions
and does not require huge amounts of input data.
They are most common in smartphones and tablets,
but larger touch screens can also be found in public
places such as airports and shopping centres.
There are three different types of touch screen
technology: resistive, capacitive and infra-red.

Resistive Screens
These are the most common type of touch screen. The
name resistive relates to resistance – the amount of A customer uses a touch
downward pressure made on the screen by the user. screen to give feedback.
The pressure causes a change in the resistance, or an
increase in voltage. The layers of the screen detects
the voltage change and calculates the co-ordinates of
where the pressure change has happened. This then
enables the processor to react to the pressure and
display the item the user requires.

42 Hardware

SB CS PP.indb 42 14.5.21. 14:13


Chapter 3
Capacitive Screens
In a capacitive touch screen, there are four electrodes at each corner that maintain an even amount WORD ALERT
of voltage across the whole touch screen. Capacitive technology works on the basis of the human
body being naturally conductive, and the electrodes cause a small current flow between the human Conductive: heat and
finger and the screen. As with a resistive screen, this current flow causes a voltage change, which is electricity can pass
used by the processor to calculate the co-ordinates where this change occurred. through an object.
Electrodes: a conductor
Capacitive screens are more expensive to manufacture than resistive screens, display better quality
where electricity enters or
images and also the ability for multiple touch sensing.
leaves an object.

Infra-Red Screens
While capacitive and resistive screens work through pressure and conductivity, infra-red screens
emit a constant grid of lights underneath the top surface layer. The technology works when this light
grid is interrupted, and a touch on the infra-red screen causes a disturbance. The disturbance is then
located by the processor and translated into co-ordinates.
An infra-red screen is much more sensitive than capacitive or resistive screens, and only requires a
very light touch to create the interruption. This means that the screens can be much more durable,
however they are susceptible to false touches because of the increased sensitivity.

Scanners
Scanners are used to convert text or images on paper
into digital information as follows:
• A paper document is placed on the scanner and a
beam of light is shone onto the paper.
• This light reflects onto a sensor, which determines
the colour of the text or image on the paper.
• The information is used by the computer, as an input,
to create a digital copy of the document.
Scanners can also be used alongside software called
optical character recognition to convert written ENRICHMENT
text into digital text, however some words may not be
converted accurately because of the handwriting. Scanned documents
A paper document being scanned have replaced many
You might also use a scanner to preserve and save old using a flatbed scanner. forms of paper-based
photographs. communication. How
The most popular type of scanner is a flatbed scanner, is this technology
however handheld scanners and specialist film scanners being used in business
to replace things that
perform similar functions.
have traditionally
Scanners can also work in three dimensions and use involved paper?
reflected laser light to build up a D model of a
scanned object. These images can then be used with a
D printer to create a model.

Camera
WORD ALERT
A web camera (webcam) takes a digital image of the
view in front of its lens. If the camera takes set images
Video conference:
one after the other at a high enough frame rate, this a form of visual
can be viewed on a computer screen as a video feed. communication where
These videos can then be sent from one computer to users in different places
another in the form of a video conference. can see, hear and speak to
Web cameras are either stand-alone devices connected each other using a variety
of equipment, including
by a USB port, or they can be built into a laptop or PC
web cameras, monitors
monitor just above the screen. A web camera (or webcam) used for sending and microphones.
digital images to other users.

Hardware 43

SB CS PP.indb 43 14.5.21. 14:13


Chapter 3
These cameras can also be used for security purposes by recording images when movement
is detected in front of the lens. Another popular use of webcams is viewing attractions such as
landmarks or tourist destinations over the internet.

WORD ALERT
Microphone
A microphone is used to convert sound
Analogue signals: analogue signals into digital information. In
continuous signals that computers microphones are mainly used with
cannot be processed webcams for video-conferencing. The digital
by a computer until signals are sent to another computer user and
they are converted into can be heard as a sound. They are also useful
digital data.
for gaming so players can speak to each other
Dictation: the process during multiplayer games. Microphones can
of reading words into also be used with dictation software to convert
a microphone so that
spoken words into digital text.
they can be converted
from analogue signals to Many computers have microphones built in,
digital words on a screen. but external microphones and those built into
specialised headsets are attached to computers
using the audio port.
A computer microphone for converting
Barcode Reader vocal signals into digital information.

REFLECT

Does the language or


dialect you speak make a
difference to computers
when you are speaking
into a microphone? How
does a computer ‘get
used’ to your voice?

A handheld barcode scanner reads


a barcode with infrared light.

A barcode reader is often found attached to a point of sale (POS) computer in a shop or business.
The reader accesses information about a product within the store. The barcode holds information
such as the product identification number, country of origin and manufacturer. However, it does
not store the price of products, which is held in a database. During the purchase process the
computer scans the barcode information and matches the data to the database to check the
most up-to-date price.
The barcode scanner uses infra-red light to read the bars in the code. This light is reflected back to
the device and is converted into digital data. Barcodes are also used for tracking parcel deliveries or
baggage in airports.

44 Hardware

SB CS PP.indb 44 14.5.21. 14:13


Chapter 3
Quick Response Scanner
A quick response (QR) scanner is a device
that reads QR codes. QR codes tend to look
REFLECT
like square patterns. The codes in the pattern
contain a small amount of data as information
Why would you use
such as website URLs and contact details. Many QR codes instead of
smartphones have QR readers and the codes barcodes?
can be scanned quickly to access information.
The codes avoid the user having to remember
long telephone numbers and website
addresses, because the QR reader will quickly
convert the QR code into the information.

A smartphone is used with a


built in QR scanner.

. Output Devices


Output devices are the hardware a computer uses to display or send out the data that has been
processed. Input devices that provide the computer with the instructions are linked to the output
devices, so the user can see or hear the results of those instructions. The choice of output device WORD ALERT
depends on the most appropriate use of the data that has been processed.
Array: a data structure
Monitor that holds related data.

A monitor or a screen is a common output device that comes in various sizes and shapes and has
different uses depending on the data being processed and output. DEFINITION
• Monitors are measured diagonally from one corner to another in inches, e.g. a -inch screen.
• The picture that a monitor can display is made up of thousands of coloured dots. These are called HDMI: high-definition
multimedia interface
pixels.
technology displays
• Liquid crystal display (LCD) monitors use a combination of red, green and blue to make any colour high-definition images
of pixel required for the output. and sound through a
• Light emitting diode (LED) screens use an array of light emitting pixels. single cable. HDMI is a
• Monitors can display a certain number of pixels depending on the quality – more pixels mean a standard connection port
better quality of picture output. for audio/visual devices in
computers.
• However, the larger the monitor the more
expensive they tend to be.
• Most laptop computers come with small
monitors built into the case, whereas
PC towers tend to have stand-alone
external monitors.
• Modern monitors connect to a
computer using a high-definition
multimedia interface (HDMI)
connector.

A large screen monitor in


use in an office.

Hardware 45

SB CS PP.indb 45 14.5.21. 14:13


Chapter 3
Touch screens
A touch screen can be used both as an input
device (refer to page ) and an output device.
Touch screens are used on smartphones and
tablets. They are menu- and choice-driven and
require a user to interact with the screen for it
to work correctly. Once the user has made a
selection with a finger press, the screen reacts
by displaying a different screen.

Digital Light Processing (DLP)


Projector
• A digital light processing (DLP) projector is
a device that connects to a computer and a
monitor to project the video output from the
computer onto a wall or a whiteboard. The A touch screen being used to
video can be viewed at a much larger size select icon options.
when projected.
• They are often used in school classrooms or home cinemas for showing video or presentations.
• Projectors are often fixed to the wall or ceiling but can also be portable.
• They are connected to a computer with a high-definition multimedia interface (HDMI) connector.
• DLPs can be large and use powerful bulbs to project the image.

A projector being
used to display a
computer image
at a conference.

Liquid Crystal Display (LCD) Projector


A liquid crystal display (LCD) projector works in a similar way to
a DLP projector. However, the key difference is that red, green
and blue lights are shone through three prisms, then brought
together, or converged, through a second prism to produce the
image. LCD projectors tend to display more vivid images than
DLP projectors, however they are often larger and heavier.

An LCD projector.

46 Hardware

SB CS PP.indb 46 14.5.21. 14:14


Chapter 3
Laser Printer

A laser printer produces a printed


output by transferring powdered toner
onto paper using heat.
The printer connects to a computer
using a universal serial bus (USB)
interface, or wirelessly across a network.
This is a very common type of printer
because it prints quickly and produces
good-quality results either in black
and white or colour, depending on the
model of the printer.
The quality of output and the low
noise levels make laser printers popular
A laser printer commonly found in a choices for workplaces.
business workplace.

Inkjet Printer
An inkjet printer
commonly found in a
home office.

Inkjet printers They work by spraying ink Inkjet printers can The printer connects
are the cheapest directly onto paper as it is produce either black to a computer using WORD ALERT
type of printer. heated by the printer. The and white or colour a universal serial bus
ink flows from a cartridge output and are (USB) interface, or Interface: a device
through tiny holes and popular choices for wirelessly across a or program used to
when the paper is fed out use at home and for network. communicate with a
from the printer the ink is printing photographs. computer.
still slightly wet.

Hardware 47

SB CS PP.indb 47 14.5.21. 14:14


Chapter 3
D Printer
ENRICHMENT
Three-dimensional or D printers are output
The 3D printer has devices that can create objects rather than
changed the way that printed pieces of paper.
organisations carry out
D printers often use heated liquid such
their planning. Can you
as plastic or metal. The type of liquid used
find out the different
depends on the item being produced. This
types of materials that
liquid is given instructions by the computer
a 3D printer uses to
to create a surface and then it solidifies.
produce models?
The printer uses several layers of this liquid
material to create the shape.

D printers are used mainly by designers to


create prototypes of objects and have been
used in car manufacturing for many years.

The printer is used with a computer and


computer aided design (CAD) software.
A D printer prints a blue model.

ENRICHMENT

Large actuators can be


Speakers
used to control flood
defences on large rivers, Most computers are fitted with a
which protects towns speaker, which produces sounds to
and cities. Can you alert the user to a problem or to a
find another example decision to be made. Speakers are
of a large actuator in also used to output music, sound
current use? and video soundtracks for a high-
quality multimedia experience. The
sound quality the computer produces
depends on the type of speaker
WORD ALERT used. The internal speakers supplied
as standard within a computer tend
Sound card: an internal to produce lower quality sound,
device of a computer but externally powered speakers
that provides a method connected to a computer’s sound
of input and output of card through an audio port produce
audio signals for use with better quality output. A pair of external computer speakers.
multimedia applications.

Actuator
An actuator is a mechanical motor that carries out an action
when a computer gives it an instruction. For example, a digital
camera has an actuator built into the lens and the motor moves
the lens in and out depending on the level of zoom required. It
is the actuator that controls this movement. Actuators can be
small, as in the case of a camera, or can be large, such as those
that control heavy duty computer-controlled drills.

A digital camera with an actuator


built into the zoom lens.

48 Hardware

SB CS PP.indb 48 14.5.21. 14:14


Chapter 3

. Sensors
Sensors are usually external devices that are
connected to a computer for measuring
something, such as temperature, light or moisture.
The sensor tends to be located in a suitable
position for collecting the information, and then
sends measurements at regular intervals to the
computer for analysis. These measurements are
converted into readable data. For example, sensors
are used to detect certain changes in a home and
automatically turn the central heating on when
DEFINITION
the temperature drops below a set level.
Small microprocessors can be used in situations Microprocessor:
where a portable computer is needed, for example Microprocessors are
in a restaurant kitchen. integrated circuits that
contain all the functions
A moisture sensor.
of a CPU of a computer.
Types of Sensors

Sensor Data captured Example of use Data type

Acoustic Sound levels At a concert Decibels


Accelerometer Whether an object is Fitness tracking Kilometres/miles per
static or in motion; can devices hour
detect motion changes
Flow The amount of liquid Medical equipment Millilitres, vapour
or vapour that passes pressure LINK
through them WB

Gas The presence of gas Used by gas Cubic metres/feet Consolidate your
engineers understanding by
completing Exercise 1,
Humidity and The amount of moisture Air conditioning Grams per cubic
page 32 in the Workbook.
moisture in the air systems metre
Infra-red Light in the infra-red Professional sporting Voltage (on or off )
spectrum – often used for events such as the
measuring distances javelin
Level Height of liquid In rivers that flood Millimetres, WORD ALERT
regularly centimetres, metres
Light The level of ambient light Security systems or Lux Ambient: the immediate
streetlights surroundings.
Magnetic field The strength of a Satellite navigation Tesla Pressure: continuous
magnetic field and GPS systems physical force exerted on
an object.
pH Acidity or alkalinity of a Water treatment or pH
liquid sewage systems
Pressure The pressure of gases or For measuring Millibars, Newtons
liquids in a system weather
Proximity Can detect the presence Security systems Centimetres
of objects without any
physical contact
Temperature Changes in the ambient In a kitchen for food Degrees Celsius or
temperature of a room or safety purposes Fahrenheit
object

Hardware 49

SB CS PP.indb 49 14.5.21. 14:14


Chapter 3

Activity
Read each of the following scenarios. Select from the table above the most appropriate sensor(s)
for each task. State why this is useful for the user.
A A shop owner wishes to improve security in their store and is also keen to find out how
many customers are visiting the shop each day.
B A band is playing a series of differently sized venues over a three-week period and wants to
set the correct sound levels for their sound system.
C A science laboratory is growing vegetables in a small greenhouse and needs to see how
well the plants are doing over the period of  months.

. Data Storage


It is important to know the differences between memory and storage before we begin to
understand their purpose within a computer system.
DEFINITION
• Memory is the microchips, transistors and capacitors that store all the instructions a computer
Volatile: loses its needs to operate. It can be volatile – one type of memory (RAM) loses its content when a
contents when there is computer is powered off, but the other type of memory (ROM) has a fixed set of instructions and
no electrical charge. these cannot be changed or overwritten.
• Storage refers to the devices within a computer where user information and data such as files,
documents, applications, video and music is kept. This storage is non-volatile, and the contents
remain stored even when the computer is powered off.
Memory is referred to as primary storage because it is essential for the computer to function, to
power up correctly, and ensures that the input, storage and output devices are able to start. There
are two types of primary storage: random access memory (RAM) and read only memory (ROM).
Secondary storage refers to hard disk drives and other types of flash storage devices that are used
for storing user data.

.. Primary Storage


LINK

See section 3.1.2. Random Access Memory (RAM)


As explored earlier in the chapter, the memory component of the CPU is important to store
instructions and a list of processes that a computer needs regularly while processing data. It is also
a much faster way for a CPU to obtain these instructions than retrieving them from a secondary
storage device like a hard disk. This component is called random access memory (RAM) because
the CPU can directly access any part of the memory. RAM is a type of volatile memory as it does not
retain its contents when the computer is powered off.

Read Only Memory (ROM)


Read only memory (ROM) contains the vital instructions a computer uses when it is first powered
up. The ROM will initialise all the component parts and will enable the input and output devices to
communicate with the hardware inside the computer. The ROM also contains instructions on which
secondary storage device to access first to enable the operating system to load. Once the ROM
instructions have all been carried out, the RAM is then used as the primary storage. The CPU can
access the ROM directly.

50 Hardware

SB CS PP.indb 50 14.5.21. 14:14


Chapter 3
.. Secondary Storage
Secondary storage is any device that is used by a computer to store data longer term. This can
include internal or external hard disk drives, solid state drives, flash storage such as pen drives and
optical storage. Unlike primary storage components, secondary storage is not accessed directly by
the CPU. Secondary storage is non-volatile, meaning that it retains data even when a computer is
powered off.
There are three different types of secondary storage: magnetic, optical and solid state. Each has
different characteristics and uses.

Magnetic Hard Disk Drive


A open view of an internal
magnetic hard drive.

WORD ALERT

Platter: a circular
magnetic plate that is
used for storing data in a
Magnetic hard drives are the most common hard drives inside computers. The hard drive consists
hard disk.
of a stack of round metal plates, known as platters. These platters are coated in a magnetic material.
Data is stored within this magnetic material and the platters rotate very quickly on a spindle. An Electromagnetic: the
electrical and magnetic
electromagnetic read/write head, which looks a little bit like a needle, can access, add and remove
forces or effects produced
data from the platters. The head never touches the metal platters because it floats on an air layer
by an electric current.
created by the spinning of the plates. If the head did touch the platters, or some dust was able to
access the drive, this would be enough to damage the device.
This type of storage is known as non-volatile storage. Non-volatile means that the device keeps its DEFINITION
data stored when the device has no power. The storage device is connected directly to the
motherboard of the computer, usually using a Serial advanced
serial advanced technology attachment (SATA) technology attachment
cable. The hard drive also requires power and is (SATA): a type of cable
connected with a second cable directly to the usually found inside
computer’s power supply. The hard drive is computers. It connects
securely mounted within the casing of a desktop a hard drive with the
or laptop computer. For this reason, fixed hard motherboard.
drives do not need much in the way of external
protection, as they are protected by the casing of
the computer itself.
When a magnetic hard disk has been used and
re-used several times, data can be moved around
the disc and split into different sectors, which can
slow the access to the data by the computer. This
is known as fragmentation – hard disk drives often
have to be defragmented in order to improve the
access to them.
A portable external magnetic hard drive.

Hardware 51

SB CS PP.indb 51 14.5.21. 14:14


Chapter 3
A portable magnetic hard drive works in the same way as a fixed hard drive. However, the platters
and read/write head are much smaller, and the hard drive is protected by a durable casing. The
DEFINITION drive is usually connected to a computer using a universal serial bus (USB) connection, or a faster
lightning connection.
Lightning connection:
a high-speed connection
that was developed by Solid State Hard Drive
Apple for the purpose
of connecting multiple Solid state hard drives are becoming more
external devices to common in computers – mainly due to the
their computers. technology getting cheaper. Solid state drives
(SSD) are very similar to flash drives (see Pen
Drives and Flash Drives, below) as they
both use technology known as non-volatile
storage. The key difference between an SSD
and a magnetic drive is that an SSD has no
moving parts. This means that the transfer of
LINK
data between the drive and the computer
processor is much quicker. As with the magnetic
See Chapter 10 Boolean
Logic.
drive, this device is connected directly to the
motherboard of the computer, usually using
a SATA cable. An SSD also requires power so is
connected directly to the computer’s power
WORD ALERT
supply with a second cable. A solid state hard drive.
In this type of non-volatile storage, the computer forces electrons to be stored within a series of
Capacitor: a small transistors and capacitors. The transistors hold their electrical charge so data can be stored in the
electronics device that capacitors for a period of time without electrical power. When the device is reconnected to the
stores an electrical power, the transistors are then charged up again. The forcing (or “flashing”) of electrons into the
charge. capacitors and transistors gives this type of device its name – flash storage. This type of storage
does degrade under extreme temperatures and the lifespan is determined by the number of
read/write cycles.
SSD such as flash memory use either NAND or NOR technology. The main difference between these
is the way the memory cells inside the semiconductor chips are wired together.
• NAND (NOT AND) technology is better for writing and erasing data, and is cheaper to
manufacture. NOR (NOT OR) technology is better for reading data. Therefore, NAND technology is
more common in computing devices.
• A NAND flash memory device contains transistors called control gates and floating gates,
ENRICHMENT and the writing and erasing of data to the device takes place within this component. Control
gates sit on top of floating gates. Electrons that register as a , as opposed to a , are squeezed
Computers are now through the gates and are stored as the data that the user requires. When this flow occurs, the
increasingly sold with
electron value changes from  to .
minimal internal storage,
and users have ‘cloud’ Portable SSDs are also becoming more popular. These are essentially high-capacity flash storage
storage instead. What drives that connect to a computer using a USB connection or a faster lightning connection.
do you understand
about storing files
and documents in the Pen Drives and Flash Drives A folding USB pen drive.
cloud, and what are Pen drives and flash drives are remarkably similar
the advantages and in terms of their general characteristics, and
disadvantages of doing so? both are non-volatile flash storage devices.
A flash drive is a collective term for any
drive that uses flash technology to store data.
LINK Examples include pen drives, card readers or the
storage inside small devices such as digital cameras or television set
See the reference to non-
top boxes. While flash drives do not have unlimited capacity storage space, they
volatile storage earlier in
the chapter. do tend to have enough to store a large amount of data depending on the purpose.

52 Hardware

SB CS PP.indb 52 14.5.21. 14:14


Chapter 3
A pen drive, sometimes known as a thumb drive, is a type of flash drive that is designed to insert
directly into a USB port on a computer. Pen drives tend to be smaller in capacity than other flash
WORD ALERT
drives, because their main intended use is portability – they can be moved between computers
for transferring data from one to another. While pen drives are very useful, it is important that they Portability: the ability to
are not used as the only storage device for personal data; as discussed earlier, the nature of flash carry or move something.
storage means that the technology degrades over multiple read-write cycles, and data could be lost. Degrades: breaks down
Pen drives are often used as personal data backup storage devices. or deteriorates.

Optical Drives
Some desktop computers are fitted with an optical disc drive. These drives
can read from and write to a variety of media, including compact discs (CD),
digital versatile discs (DVD) and Blu-ray discs (BD). Optical disc drives are so
called because they use laser light and the light spectrum to read or write
the data. Optical drives are becoming less common in desktop or laptop
computers as manufacturers attempt to make devices slimmer and lighter.
They are, however, a common feature of games consoles.
• Compact disc (CD) drives: The most basic CD drive can only read a
software application CD or an audio CD. However, CD-R/W/RW drives
(CD readable/writable/re-writable) are also capable of writing and/or re-
writing data to compatible media. Basic CD drives have been a feature of
An optical disc drive.
music stereo systems for many years, and the CD is still a popular format for
delivering music to consumers. REFLECT
• Digital versatile disc (DVD) drives: DVD drives are similar to CD drives, in that the basic drives
can only read applications or video formats such as films. DVD-R/W/RW drives (DVD readable/ What advice would you
give to somebody who
writable/re-writable) are also capable of writing and re-writing data to discs. Stand-alone DVD
told you that they only
players are common in many home media set ups, and the DVD is a popular format for distributing use their flash storage
films and computer applications software to consumers. drive to store important
• Blu-ray disc (BD) drives: Many newer laptops and games consoles are fitted with BD drives. files or documents?
This format is popular for distributing high-definition media content to consumers. The term
Blu-ray refers to the blue laser that reads the data on the disc, which uses a much shorter
wavelength than the standard red laser in CD and DVD disc drives. This shorter wavelength
means much more information can be stored on a BD, even though they are the same physical REFLECT
size as CDs and DVDs.
Optical discs have
Optical storage devices such as CD/DVD/BD-rewriting drives use the in-built laser to create and read
changed over a short
pits and lands as the disc spins. A pit represents a  and a land represents a  to enable data to be
space of time, and there
reflected or digitally read from optical media. When data is being written to an optical disc, a read/ was quite a rapid move
write head moves across the surface of the disk and the laser burns a pit into the surface of the disc. from CD to DVD to Blu-ray.
These pits and the spaces between the pits (lands) enables the laser to reflect back and convert the It looks now like the days
data to ’s and ’s – binary data, that is ready to be processed. of the optical disc will
soon come to an end. Can
you think of anything you
do that would be difficult

. Virtual Memory if you didn’t have a disc?

Virtual memory is created by a computer when it has many processes running at the same time. ENRICHMENT
Sometimes, the RAM can become overloaded with trying to process too many instructions at once,
so the operating system will use a portion of the secondary storage, usually the internal hard disk, Many games consoles
are moving away from
and will designate it a temporary area of RAM.
disc-based games and
This type of memory is much slower because the data is having to travel much further than if it was are moving to something
contained within the actual RAM. called DLC (downloadable
content). Why do you
Another thing that causes the computer to operate more slowly is the process of paging or swapping data
think the disc is now
between the virtual memory and the RAM. Paging is where the computer will move instructions that it used less?
does not currently need out of the RAM into the virtual memory and swap in instructions that it does need.

Hardware 53

SB CS PP.indb 53 14.5.21. 14:14


Chapter 3

ENRICHMENT
. Cloud Storage
With cloud storage, files, data, documents, images, music
Do you think that the
and video are stored in a remote location. Users
commonality of solid state
hard disks will improve
purchase some space on an external server that is
virtualisation? Is there an located somewhere in the world, and access it via
improvement that could the world wide web. The server is connected to
be made to the technology the internet and can be downloaded from and
of RAM that would remove uploaded to as necessary.
the need for virtual
Cloud storage is often used as backup and
memory?
is also very good for sharing files with other
people. The other advantage is that data can
be accessed from anywhere with an internet
connection.
The disadvantage of using cloud storage is that
if there is no internet connection then the files
HELPFUL NOTES cannot be accessed. Additionally, it is the job of the
organisation providing the storage to ensure the security
Many mobile phone of the data, and cloud storage is just as susceptible to hackers
Cloud computing refers to data
services come with cloud as personal storage is. stored externally.
storage plans, which is
enabling manufacturers

. Network Hardware


to reduce the amount
of flash storage inside
a phone. This frees up
space for users to install
more applications on
their phones, as we
increasingly rely on
mobile technology to
access essential services.

LINK WB

Consolidate your
understanding by
completing the Exercises
1-3 from pages 34-38 in
the Workbook.

Computers worldwide connected to the internet.

A computer requires certain hardware to access a network. This hardware is a network interface card
or controller (NIC), and it provides the computer with wired or wireless connections to a network.
When the controller is manufactured, it is given a unique media access control (MAC) address, but
this should not be confused with an Internet Protocol (IP) address.

54 Hardware

SB CS PP.indb 54 14.5.21. 14:14


Chapter 3
.. Media Access Control (MAC) Address
DEFINITION
When the controller connects the computer to the internet, the MAC address gives the controller a
unique address and identifies the device on the network. Hexadecimal: a number
Any device that connects to the internet, either wired or wirelessly, has a unique MAC address. These system that uses 16
are made up of a string of numbers, usually from the hexadecimal number system. As the number characters instead of the
is preset at the point of manufacture, the address never changes, even when you connect the 10 characters used in the
decimal system or the
computer to the internet in a different location.
two used in binary.
A typical MAC address looks like this: This half of the MAC address
The address is made up of six groups identifies the manufacturer
of hexadecimal digits and this of the NIC.
represents  bits. The first half of the
address identifies the manufacturer
of the network interface card, and
the second half is the serial number
D0 : 81 : 7A : A6 : 82 : D2
of the card.
This half identifies the
The composition of a
serial number of the
MAC address.
device.

.. Internet Protocol (IP) Address


An Internet Protocol (IP) address is a unique address issued to the device whenever it connects to
the internet. These addresses are issued either by the internet service provider (ISP) that provides the
connection or the network the computer is connected to.
It is the IP address that enables computers all around the world to communicate with each other via
the internet. Think of an IP address in a similar way to a postal address – without a postal address on
an envelope, letters would not reach their chosen destination.
IP addresses are usually four groups of digits separated by dots.
IP address Postal address
The digits are between  and , representing  bits. This type
of IP address is known as IPv and has been in use since the 63 . 41 . 136 . 21 45 New Street
early days of internet usage. This format of IP address allocation London
offers almost . billion unique addresses.
An IPv address and a W1 3BL
As the internet and its use evolved, there was a need for ISPs postal address.
England
and networks to issue increasing numbers of IP addresses, as
more devices became internet enabled. A new standard for
the protocol was introduced, called IPv, which allowed for
an increase in unique IP addresses from . billion unique IPv addresses up to an enormous 
undecillion potential unique IPv addresses. ENRICHMENT
Whereas an IPv IP address is made up of four groups (or octets) of numerical digits separated by How do you find out the
dots, an IPv address is made up of eight groups of hexadecimal numbers separated by colons. IP address of the computer
you are using?

IPv4 IPv6

63 . 4 1 . 1 36 . 21 2002 : O d a9 : 6 3a3 : 0 0 0 0 : 0 0 0 0 : 7 b 3f : 0 2 2 0 : 64 66

4 groups of 8 groups of hexadecimal


numerical digits numbers

IPv addresses compared to IPv addresses.


There are sometimes double colons within an IPv address – where one of the hexadecimal groups
contains all zeros and therefore to save computing space the additional colon marks the gap where
these groups would have sat.

Hardware 55

SB CS PP.indb 55 14.5.21. 14:14


Chapter 3

2002 : O d a 9 : 6 3a3 : 7 b 3f : 0 2 2 0 : 6 4 6 6
The IPv address from above with complete zero groups of hexadecimal numbers
replaced by an additional colon.

REFLECT When an IP address is issued to a device accessing the internet, the address can be static or dynamic.
A static IP address is created by a user in the settings of the router (see below). These are rare
What would be the
because static IP addresses can cause problems on a network if set incorrectly.
benefit of a network
administrator setting IP A dynamically issued address is more common. These are issued by routers on a network using a
addresses to static? service called dynamic host configuration protocol (DHCP). This enables a router to assign an IP
address to any new device that is connected to a network. When a device is removed or unplugged
from the network, the address is recycled to another device that may replace it. The use of DHCP and
dynamic IP addresses ensures that there is no duplication of addresses on a network and enables all
the devices to share the internet connection.

.. Routers
A router enables a home or business to connect devices to the internet and is normally provided
by an internet service provider (ISP). Routers send data to specific destinations on a network using
ENRICHMENT the IP addresses it has issued to devices at those destinations. A router creates what is called a
local area network (LAN), and often incorporates another piece of vital equipment to make this
Most home broadband connection – a modem.
systems have combined Modems are used to convert signals from a telephone
modem routers provided
or fibre optic line into data that is readable by
by an internet service
provider (ISP). What
a computer, and similarly converts data from a
would be the benefits computer into signals that can be sent down a
or drawbacks of using telephone line or fibre optic cable. Many modern
an alternative modem routers have modems built in.
and router other than
the one from the A router connects devices
broadband provider? to the internet.

Activity
You have been asked to create a small network for your home. There are eight rooms in the
house: a lounge, a kitchen, a dining room, three bedrooms, an office and a bathroom. There will
be at least one device in each room that will be connected to the internet, as in the table. Draw a
simple sketch map of how the house would be connected and what devices are required for this
connection.

LINK Room Device(s)


WB
Lounge Smart television, games console, tablet
Consolidate your
understanding by Dining Room Smart speaker
completing Exercise 1, Kitchen Smart speaker
page 38 in the Workbook.
Bedroom  Smart television, games console
Bedroom  Smart television, laptop
Bedroom  Smart speaker
Office Desktop computer, printer, smart speaker
Bathroom Smart speaker

56 Hardware

SB CS PP.indb 56 14.5.21. 14:14


Chapter 3

Let’s Map It
HARDWARE

Input Process Output

Catche
CPU
RAM
Storage CPU CPU
CU Cores
Memory
Registers CPU CPU
Unit Fetch - Decode - Execute
ALU

Buses

°C/°F
24.1° Networks
Sensors
24.2°
24.3°

Home
Server
Router
www

Cloud Storage

Hardware 57

SB CS PP.indb 57 14.5.21. 14:14


Chapter 3

Let’s Review

 What is meant by computer architecture?


 What is the job of the central processing unit?
 List the five different registers that sit within a CPU.
 Describe the von Neumann architecture.
 Fill in the gaps: the main method of processing data within the CPU is the __________ -
_________ - __________ cycle.
 Explain the purpose of a bus.
 What is the purpose of cache memory?
 If a processor has two cores, what is it known as?
 What is a processor’s clock speed measured in?
 Give an example of an embedded system.
 A touch screen as an input device can be either capacitive, resistive or infra-red. Briefly explain
the differences between each type of screen.
 What would be the most appropriate sensors to use when measuring average rainfall in an
outdoor location?
 Define what is meant by cloud storage.
 What is the difference between a MAC address and an IP address?
 How does a device that you wish to connect to the internet obtain a dynamic IP address?
 What is the main purpose of a router?

58 Hardware

SB CS PP.indb 58 14.5.21. 14:14


CHAPTER

4 Software

COMPUTER SCIENCE WATCH

Scan the page to watch a clip on


the differences between system and
application software.
Before watching discuss what you expect
to see or hear.

QUESTIONS

• What is the link between hardware and


software?
• How is software essential to the operation
of a computer?
• How do humans use software to interact
At the end of this chapter, you will be able to: with computing devices?
understand the difference between system software and application • What is programming and how do pieces
of software begin their existence?
software
define the role and basic functions of an operating system
identify the hardware, firmware and operating systems that are used
to run applications software
define the role and operation of interrupts
identify the difference between a high-level language and a low-level
language
understand the advantages and disadvantages of each type of
language
define the two types of translator: compilers and interpreters
identify the advantages and disadvantages of each type of translator
understand what an integrated development environment is used for,
including its common functions

59

SB CS PP.indb 59 14.5.21. 14:14


Chapter 4
A computer system is made up of both hardware (as we have examined in Chapter ) and software,
and both are essential for the successful operation of the system. This chapter will explore different
types of software and how they exist and work. We will also learn about how the different pieces of
software control and use the hardware of the computer.

. Types of Software


WORD ALERT There are two different types of software that a computer system uses: system software and application
software. System software is a variety of programs and processes that a computer needs in order to
Function: in order to function. System software that is embedded into hardware devices are known as firmware. Firmware is
work correctly. often installed onto components of the hardware when the computer is built and users do not need to
involve themselves with the installation of system software at all.

DEFINITION .. System Software and Application Software


Firmware: small An example of system software is the BIOS program that is installed in the Read Only Memory (ROM)
applications which of a computer. BIOS stands for Basic Input Output System, and it is a set of instructions that are
enable a computer to
executed by a computer once it receives the power to start all of the necessary hardware.
start all of its devices.
Utility: a small piece of Another example of system software is the operating system (OS) of the computer, such as Microsoft’s
software that controls Windows OS or Apple’s macOS. The operating system allows users to work with the hardware and
specific parts of applications software in a user-friendly way, usually through the operation of a mouse and keyboard.
the hardware. There are often other pieces of system software built
into the operating system that allow a user to control
the power, attached devices and memory. This type
of system software is called utility software.
Application software is the term used for any
software that a user requires in order to make use
of the computer system for their needs. Examples
of applications software are office applications
such as word processors, spreadsheet applications
and presentation software, games, web browsers
and communications software. They are not
essential to the functioning of a computer, but
they may be essential to a user’s particular needs.
LINK WB A laptop running the Microsoft
Consolidate your .. The Operating System Windows operating system.

understanding by
completing Exercise 1, Most computer systems that we interact with as users have a form of operating system installed on
page 42 in the Workbook. them, to allow us to quickly begin work or start accessing the applications that we require in our lives.
The operating system is a special piece of system software that manages many things that allow us
to use the system for our needs.
In addition to the roles explored in Figure ., an operating system is also the platform for a computer to
ENRICHMENT
run the applications software that is required by a user. Computer software developers have to ensure
Can you find out
that the software that they design, code and produce is able to be run on multiple operating systems.
about other types of Operating systems exist within various systems that require humans to interface with them. Devices such
operating system, and as personal computers, laptops, mobile phones and smart TV’s all require user interaction. There are various
their advantages and ways in which the interaction can occur, including textually through a command line interface, visually
disadvantages? Find out using a graphical user interface with point and click methods and verbally using voice commands and
about Linux, and what
natural language interfaces. Some of the current examples of this that you might find around the home
makes it different from
that use these interfaces are smart speakers such as Google Home and Amazon Alexa, as well as mobile
the other operating
systems mentioned here. based apps such as Bixby and Siri.

60 Software

SB CS PP.indb 60 14.5.21. 14:14


Chapter 4

The Operating System


Managing drivers
Managing peripherals Managing Peripherals Managing Drivers
Drivers are small utility software
Enables all attached that give specific instructions to
Enables all attached hardware to Drivers are small utility software
hardware to funtion function effectively that give specific operating
devices such as printers
effectively instruction to devices such as
printers

Managing memory Managing Memory Managing FilesManaging files


Helps us to save, retrieve and
Allows the computer Allows the computer system Helps us to save, retrieve and
to move things in and out of print files created print
files created
system to move things in memory when needed
and out of memory when
needed Handling interrupts
Manages Multitasking Provides Interface Handling Interrupts
Alert us as users when an
Enables the computer to do Allows us to interact with the Alert us as users when an action
several things at once physical hardware action needs to be carried out
needs to be carried out
Managing multitasking
Enables the computer to Provides interface
do several things at once Allows us to interact with the
physical hardware
Figure . The role of the operating system.
Creates more effective Takes less time
and efficient code to translate
As we will explore in Chapter , system security is something that all computer users have to be LINK
aware of when using devices. The operating system provides a useful line of defence, and usually has
a variety of small utility programs, such as firewalls and authentication, that help to guard against See Chapter 5.3.
threats to files. Operating systems create and manage essential user accounts such as the system
Code can be Things can be hidden
account, administrator user kept
account,
secret
COMPILER
regular user account and guest user account. Theyinare
and not detected codeable to
handle multiple users being able to access the computer, with separate profiles created for each user
VS.
based on their individual needs. This is especially important when it comes to protecting younger REFLECT
users from accessing unsuitable content. INTERPRETER

A further feature of operating systems is to manage the memory available within a system. This can Why do you think it is
Slower translation Code is more versatile, can be
involve the allocation of resources to the hardware to enable the carryingviewed
as it is line-by-line outonofdifferent
usersystems
instructions,
easily
important to enable
and also to ensure that the same memory locations are not utilised by different processes. different user profiles on a
shared computer?

.. Application Software Running Sequence Easier for beginners as errors are
easily idatified and corrected
Applications, or ‘apps’, are the pieces of software that users want or need to use as part of their lives, both in
work and leisure usage. It is a combination of the operating system, bootloader (firmware) and hardware
working together that allows application software to operate, and the sequence is crucial to that operation.

The firmware (such as The applications are


The operating system is
the BIOS) is run and run on the operating
run on the firmware
activates the hardware system

Figure . Application software running sequence.

WORD ALERT
.. Interrupts Intervention: an action
Handling interrupts are an important function of the operating system. An interrupt is a signal sent taken by someone
from a device or a program to the operating system that causes a temporary stop in the current to make something
different happen.
program. When the program is halted and control is transferred to the operating system, it usually
has a decision to make, either to continue running the program, run a different program or require a
further intervention from a user.
DEFINITION
When a device sends an interrupt signal, for instance when a user presses a key on a keyboard, the
interrupt is collected by an interrupt handler, and an interrupt service routine is carried out. Interrupt service routine:
This usually involves the interrupt being assigned a place in a queue, so that the handler can decide a software routine that
which interrupt is the highest priority. The interrupts are then handled according to their importance. hardware invokes in
This process happens so fast that it is impossible for a user to notice that the operating system has response to an interrupt.
been interrupted temporarily.

Software 61

SB CS PP.indb 61 14.5.21. 14:14


Chapter 4
There are two different types of interrupt, a software interrupt and a hardware interrupt. Software
interrupts are usually signals sent to an operating system by applications, such as a mathematical
DEFINITION
problem like a division by zero or processes attempting to access the same memory location.
Division by zero: a Hardware interrupts could be a press of a key on a keyboard, or the click of a mouse button.
mathematical calculation
that has no answer, and

. Types of Programming Language,


one that is automatically
rejected by a computer
for this reason.
Translators and Integrated Development Environments (IDEs)

All of the software that we use has to be created and coded by software developers, and the
computer programs that are created have to be translated into signals that can be understood by
a computer system. Here we will examine the processes and sequences that enable this translation
to occur.

.. High-level and Low-Level


Programming Languages
In its most basic form, computer language is made up of binary
code, which is a series of s and s. This is called machine code,
and basic instructions that a computer is required to carry out are
written in this language. Machine code is a low-level language,
and this is so named because it is the language of a computer
QUICK CHECK rather than that of a human.
As machine code is difficult for humans to program in, mainly due to
What is the key difference
between a low-level and
the difficulty in debugging the code, programmers usually write code in
high-level programming high-level languages such as Python, JavaScript, C, C++ and Java. They are
language? called high-level languages because they contain English-like words and terms Writing and
that we use in communication and are easier for programmers to understand. debugging code.
All of the programming languages listed above have evolved over a number of years as
programmers develop their knowledge of how to program a computer.

Advantages of low-level language Disadvantages of low-level language

Programmers who can write programs in These programs tend to be specific to the
low-level code will be able to create very machine they are programmed on.
effective and efficient programs that tend to
run very quickly.
Programs written in low-level code will use There are likely to be more errors and code is
both processor capacity and memory very well. harder to debug.
Low-level coding can directly change or It is much more challenging for humans to
manipulate computer hardware. write low-level coding.

Advantages of high-level language Disadvantages of high-level language

Code is easier to debug. Code has to be translated into machine code


before it can be executed.
Code is much easier to write and be read by Programs tend to be slower than those
LINK
fellow programmers. programmed in low-level code.
Programs written in high-level code tend to be Inefficiencies in hardware usage are a common
See Chapter 1.1. portable, meaning they can run on more than feature of high-level coding.
one type of machine.

62 Software

SB CS PP.indb 62 14.5.21. 14:14


Chapter 4
.. Assembly Language
HELPFUL NOTES
We discussed earlier that machine code is the binary code that is understood by a computer.
Assembly language is a type of programming that sits just above machine code and is a low-level Mnemonics help us to
language that uses mnemonics for its instructions and commands. remember complex
information. We
A mnemonic is a pattern of letters or ideas that helps a user to remember something.
often use them to
An example that may be found in assembly language is INP, which is a low-level mnemonic for Input, remember how to spell
and RET, which is a mnemonic for Return. difficult words, where
computers use them to
translate programming
Activity terminology.
What do you think the following mnemonics might represent?

CL INC HLT DEC

WORD ALERT
When a program is written in assembly language, in order for a computer to carry out the programming,
it must first be translated into machine code. An assembler is needed to carry out this task, and this is a Translated: changed into
translator application that is usually built into programming software when coding at low-level. a different language.

.. Compilers and Interpreters REFLECT


There are other types of code translation applications that are built into high-level programming
Depending on the
languages, called compilers and interpreters. Both have different characteristics, but a key feature of type of programming
these types of translator is to report errors in the code to the programmer. language, compilers
A programmer will produce a piece of code in a high-level language that is designed for a specific and/or interpreters are
purpose. It is then important that the code is tested out to see if it does what it is meant to do. used during the code
production process. It can
When a compiler is used, it will translate an entire block of code that has been created and will take hours to compile a
produce an executable file. When this code then runs, the compiler will produce an error report for large application.
the whole block of code if any errors have been detected. Examples of languages that use compiled
code are C and C++.
When an interpreter is used, it will translate and execute the code that has been written line-by- DEFINITION
line. Unlike a compiler, which waits until the end of the execution process before reporting errors,
an interpreter will stop the execution of the code when it detects an error. Unlike a compiler, Executable: a file that
interpreters do not report syntax errors at the end of the processing. The interpreter will also not launches and runs a series
produce an executable file at the end of the process. Examples of languages that use interpreted of code when opened.
code are Python and JavaScript.

Creates more effective


and efficient code Slower translation as it is
line-by-line
Code can be kept secret
Easier for beginners as
Takes less time to
COMPILER VS INTERPRETER errors are easily identified
translate and corrected

Things can be hidden Code is more versatile,


and not detected in can be viewed on different
code systems easily

Figure . Advantages and disadvantages of compilers and interpreters.

Software 63

SB CS PP.indb 63 14.5.21. 14:14


Chapter 4
When programmers are developing code, an interpreter is used for ease of debugging and a
compiler is used to translate the finished program.
WORD ALERT

Debugging: finding
errors or mistakes in code.
.. Integrated Development Environments (IDEs)
An Integrated Development Environment or IDE is an application that
programmers use to test and develop new software. An IDE allows
a programmer to write code in various different programming
languages and will simulate the running of the code so that
DEFINITION development can take place easily.
Simulate: run a test An IDE has a number of different features all designed to assist a
version of an application. programmer in their work.

Code Editor
This part of the environment is called the shell and is a text
editing area. Programmers can write their code in the shell. There
are a number of features built into this part of the IDE that can help
programmers work more efficiently, such as auto-completion, auto-
correction and prettyprint.
Coding in Python –
WORD ALERT Auto-Completion a high-level language.

When a programmer types in a common function or piece of syntax, the IDE will recognise the
Syntax: the structure start of the piece of code and suggest or complete it for the programmer. This saves time
of not just statements while programming.
but also symbols,
punctuation, etc., in a Auto-Correction
computing language.
Similar to auto-completion, an IDE can detect when an obvious error has been made and will
suggest a correction automatically for the programmer to review. Also built into this feature is
bracket matching, where the IDE will suggest or highlight closing brackets or braces that were
missed out by the programmer.
ENRICHMENT Prettyprint
There are several To make life easier for programmers, most IDEs will format code using indentation and a colour
different IDEs that have scheme to make lines and functions easier to spot. Prettyprint also helps programmers to see where
been developed for subroutines and loops sit within a larger block of code.
programmers. Download
one yourself and try
writing a simple program
Translators
– you will be surprised at As discussed in section .., translators provide a vital bridge between high-level and low-level code.
how easy it is to use! Some IDEs will have a translator built into it, and will be capable of both compiling and interpreting
code written by a programmer. Only the most advanced IDEs support almost all languages.

Error Diagnostics
LINK
When code is compiled or interpreted, the IDE will pinpoint errors, either in a report or on a line-by-
See section 4.2.3. line basis. It will show the programmer the line number of the error and indicate the type of error
that has been detected.

Run-time Environment
LINK WB This allows a programmer to execute the program one step at a time and is useful to ensure that all
parts of the code are correct before creating the final version of the code.
Consolidate your
understanding by
completing Exercise 1,
page 46 in the Workbook.

64 Software

SB CS PP.indb 64 14.5.21. 14:14


Chapter 4

Let’s Map It

HARDWARE SOFTWARE

Software and hardware are essential to work together.

SYSTEM APPLICATION

Allows a Allows a
computer to computer to
function be used

Operating System Applications are required to enable a user to


Enables a user to interact with the computer. carry out tasks and work.

Interrupts All software starts as code

A stop in a process needing a user or program input.

1 Python Perl C++ Java C#


2 Handled in order
3 of priority.
4

Integrated Development Environment Low- and high-level languages

X
1
2
if a == 10:
3
00110 111001 b += 1
4
5 Low High
6
Code 7
Editor 8 Simulation Translator
9 Compiler/Interpreter
10
11

Software 65

SB CS PP.indb 65 14.5.21. 14:14


Chapter 4

Let’s Review

1. Name two different types of system software.


2. What are three main features of an operating system?
3. What is the function of firmware in a computer system?
4. Complete the sentence. An interrupt is where a piece of software requires...
5. What are the two different types of interrupt?
6. Give one example of a software interrupt.
7. What is the difference between low-level and high-level programming languages?
8. Why do programmers mainly use high-level languages to write their code?
9. What is a definition of assembly language?
10. Name the two types of translators found within programming.
11. What are the main reasons for choosing between the two types of translators?
12. Why is it a good thing for a programmer to check their code line-by-line when developing
a program?
13. What does IDE stand for?
14. Name two functions of an IDE.

66 Software

SB CS PP.indb 66 14.5.21. 14:14


CHAPTER
The Internet and
5 Cyber Security

COMPUTER SCIENCE WATCH:

Scan the page to watch a clip on common


types of cyber-crime.
Before watching discuss what you expect
to see or hear.

QUESTIONS

• What is the difference between the internet


and the world wide web?
• How do we access and use websites
At the end of this chapter, you will be able to: effectively?
• What exactly is digital currency?
explain the difference between the internet and the world wide web • How important is it to keep our computers
understand what is meant by a uniform resource locator (URL) safe from cyber-crime?

explain the purpose of the hypertext transfer protocol (HTTP) and the
hypertext transfer protocol secure (HTTPS)
define how a web browser operates and what functions it provides
understand how web pages are found, retrieved and displayed on
your computer
explain what is meant by a cookie and why they are used
understand the concept of a digital currency and how blockchain is
used to keep track of digital currency
understand a range of cyber security threats and the solutions used
to protect data from these threats

67

SB CS PP.indb 67 14.5.21. 14:14


Chapter 5
One of the greatest developments in computing during the late th century was the introduction
of the internet into our working and home lives. The ability to communicate on a global scale both in
business and leisure has opened up infinite possibilities for users all around the world. However, with
HELPFUL NOTES
these opportunities also come risks, and with user data increasingly being shared across computer
networks, the need to be safe and secure in our practices online is of paramount importance.
The idea of a world wide
web was created by Sir
Tim Berners-Lee, a British
computer scientist. He
decided to gift the idea
to the world and did
. The Internet and the World Wide Web
not make any money
from the idea. He also It is important to know the difference between the internet and the world wide web. The two terms
published the world’s first are often used interchangeably and wrongly, so it is vital to ensure that the differences are known.
website in 1990. The internet is the enormous network of computers, devices and hardware that are all connected
together as a set of small networks enabling communication between devices to take place. This is
known as infrastructure and represents all of the physical pieces of equipment connected through
service providers to servers all around the world.
The world wide web is the collection of websites and web pages that store the information that
users wish to access. These web pages are stored on servers and users access them using the
internet infrastructure.

.. Uniform Resource Locators


Just like houses and homes have unique postal addresses to identify where they are in a given
QUICK CHECK country or city, websites and web pages also have addresses to help users find them.
These web addresses are called Uniform Resource Locators, or URLs for short. They enable a user to
What are the important locate a website easily by typing the URL into the address bar of a web browser. A URL can contain
pieces of information
the protocol, the domain name and the web page/file name.
that are required for the
receiver’s address on an Every website address has a URL with an equivalent Internet Protocol (IP) address. IP addresses
envelope when sending a are made up of numbers and letters and can be very difficult for a user to remember. Refer to
letter through the post? section .. for more information on how IP addresses are matched to website addresses.

Worked Example
A website for a company called My Favourite Cars might have a web page with a web address
of http://myfavouritecars.com. This URL is much easier to remember than the website’s actual IP
address which might be something like .... The URL is better to give to people looking
for the website and is much more memorable than a string of numerical digits.

Just as a postal address has certain items in it that identifies a house, a URL also has identifying
elements. With some or all of these missing, a letter may not arrive at its intended destination.

Postal address example

, City Road House number and road name


Strickland Town or city
Walthamshire County, state or province
England Country
WE QQ Postal code

The same is true of a URL. If you only know part of the address, you may not get to the website that
you require.

68 The Internet and Cyber Security

SB CS PP.indb 68 14.5.21. 14:14


Chapter 5
These are the elements of a URL:
• protocol
• domain name
• folder structure leading to where the webpage is located
• name of the requested web page
http://clotheswarehouse.com/clothes/shirts

Protocol Domain name Area within website Web page name


http:// clotheswarehouse.com clothes/ shirts

The whole address then takes a user directly to the part of the website that they wish to view. In the
example above, the website is a business site with a domain name ‘clotheswarehouse.com’ and the
user wishes to access the exact page containing shirts sold by the business. Each element of URL will
be further explained in subsequent sections.

.. Hypertext Transfer Protocol and Hypertext


Transfer Protocol Secure
Data packets are sent around the internet
using different protocols, or rules. The protocol DEFINITION
that web pages use for data transfer is called
hypertext transfer protocol (HTTP) and all Hypertext transfer protocol:
URLs begin with the letters ‘http’. the agreed set of rules
that all computers use for
The internet is also capable of providing other
transmitting files (data)
means of data transfer, and different protocols over the world wide web.
exist to ensure the correct packets of data reach
their intended destinations. Some of the other
services that the internet provides include
email, file sharing and video streaming.
QUICK CHECK
Data can contain private or sensitive
information, for example, users’ personal Keeping your data secure is crucial when using What types of information
the internet. do you think you might
information from their online bank accounts,
or payment card details when purchasing an item from a website. When these packets of data are share when buying an
transmitted across a network, it is vital that this information remains private and secure to prevent item online?
criminals from accessing potentially sensitive information.
When using websites such as online banking or making online purchases, you will notice that, when
completing a transaction, the protocol changes from just hypertext transfer protocol (http) to secure
hypertext transfer protocol (https). This can be noticed by looking at the address bar of the
browser being used to access the web page.
Secure http ensures that a secure connection is made between the two devices engaging in the
transfer of data. The data packets are encrypted before they are transmitted across the network and
are decrypted only when they reach their intended destination. This ensures that criminals such as
hackers would be unable to access the private and confidential information as they would be unable
to decipher the encryption. Any data that was intercepted during this process would be meaningless
to the hacker.
The process of encryption requires the devices at either end of the transfer to use an encryption
key to unscramble the secure data. Websites built with encryption technology will give users the
confidence to carry out these transactions.

The Internet and Cyber Security 69

SB CS PP.indb 69 14.5.21. 14:14


Chapter 5
.. Web Browsers
The main application on a computer that is used to retrieve and display web pages is called a
ENRICHMENT web browser.
Most web pages are written in a variety of different programming languages, including Hypertext
How have websites
Markup Language (HTML) and JavaScript, or make use of cascading style sheets (CSS). The job of the
evolved over the years?
Name some things you
web browser is to translate HTML code from websites and display it to the user as web pages.
can do on a website that Other functions of a web browser are as follows:
you couldn’t have done
10 years ago.
This is the ability to store the URLs of your favourite
websites as bookmarks for future reference. Modern
Bookmarks
browsers allow you to create quick link buttons to
and favourites
enable faster access to these websites and cut out the
need to type the URL each time.

A web browser can store a list of recently viewed web


Recording pages in reverse date and time order. This list will keep
user history growing from the first use of the browser until it is
cleared by a user.

Allowing the
Users can open multiple web pages in different tabs,
use of multiple
enabling several sites to be accessed at the same time.
browsing tabs

Cookies are tiny files that are saved to your computer


HELPFUL NOTES
when you access a website. They can be used to store
A phone book is a your personal preferences or your activity within that
directory containing all Storing cookies website. Cookies enable websites to display relevant
of the listed telephone advertisements that the browser thinks may be of
numbers for a town. interest to you, based on your browsing history within
While web servers do a particular website (see section ..).
not contain a book, as it
would be immediately
out of date, the DNS uses A web browser contains various icons and buttons at the
nameservers to locate top of the window, including a back button, a forward
different websites. Providing tools button and a home button. These navigation buttons
for navigation enable a user to move smoothly between all previously
viewed web pages without the need to re-enter
DEFINITION
their URLs.

Search engine: a web-


based tool that is used to This is where a user can type in the URL for a website
find web pages based on they wish to visit if they know the web address. Modern
Providing an
a given topic or keyword browsers will also use the address bar to access the
address bar
entered by the user. It facilities of a search engine if it does not recognise the
then returns a list of URL immediately.
relevant web pages and
their respective URLs.

70 The Internet and Cyber Security

SB CS PP.indb 70 14.5.21. 14:14


Chapter 5
.. Locating and Viewing a Web Page
As discussed in sections .. and .., web pages are located on a server somewhere in the world. It
is the job of the web browser to retrieve the web page for the user to view. WB LINK
It is firstly important to know the URL of the site or page that the user wishes to retrieve. This is
Consolidate your
typed into the address bar of the web browser. The browser then makes a request through the user’s
understanding by
internet service provider (ISP) to locate the web page that has been requested. This process is called completing Exercises 1
making a Domain Name System (DNS) Query and is like looking up someone’s phone number in a and 2, pages 50-53 in the
phone directory. Workbook.
As we learned in section .., each website has a URL that is linked directly to a unique IP address.
The DNS Query uses the URL that has been entered by the user and looks up the matching IP
address. The IP address then connects the user’s browser to the web server that hosts the site and
retrieves the required website for the user to view from the database.
It is the job of the browser to firstly request the files for the webpage from the DNS and then
translate all of the data that the DNS Query returns into HTML code (see section ..) so that a user
can interact with the website. ENRICHMENT

.. Cookies Cookies can be switched


off on websites. What do
Cookies are very small text files that are stored on your computer when you are browsing the world you think would change
wide web and websites. They are sent to your computer by the web servers that hold the websites about your website
browsing if you did so?
you are visiting.
Cookies are designed to personalise your user experience while browsing a particular website.
They are generally used to:
• store user preferences on a website Session Persistent
• store login details cookies are cookies have
• track user behaviour temporary cookies that expiration dates and are
• store items in online shopping carts are deleted when you close stored in a folder on your
your web browser. They provide computer until they expire
• help advertisers show relevant
information on your browsing or the user deletes them. They
website adverts based on user’s
while you are on that particular make websites appear to
browsing habits
website and this is not remember a user on the
There are two different types of cookies retained once you close next visit.
that are stored. your browser.

Worked Example
If you have been recently on a website that sells sunglasses, and you have browsed several
designer brands of sunglasses, the web server of that site will have sent your computer some
cookies that have been designed by those designer brands.
As you then make your way around other websites that contain adverts and advertising space,
those cookies will activate and you will begin to see adverts for designer sunglasses, even if the
site you are viewing has nothing to do with designer sunglasses. This is because your preference
for the designer brands you viewed previously has been stored in their cookies and their cookies
have been accessed in order to find and display an appropriate advert. This is an example of a
persistent cookie in use.
Look out for this next time you are browsing, particularly if you are visiting shopping websites.
Some users consider that browsers collecting data in this way is an invasion of privacy and could
lead to criminal activity like identity theft.

Users do have the choice on a website to disable cookies, however this can affect the user
experience and make browsing less interactive.

The Internet and Cyber Security 71

SB CS PP.indb 71 14.5.21. 14:14


Chapter 5

HELPFUL NOTES
. Digital Currency
Bitcoin has been in As the world moves to operate in ever more digital situations, traditional methods of exchanging money
existence since 2008 begin to be joined by digital currencies.
and, although it is not
fully accepted as a A digital currency is one that exists electronically. It is a method of payment, but rather than
method of payment by exchanging physical coins and bank notes, the payment is made electronically. Payments made
many organisations, it using this cryptocurrency are encrypted. It also operates using what is known as a decentralised
is considered a highly system. This means that there are no central banks to keep track of payments, instead a system
efficient way of doing known as a digital ledger is used for cryptocurrency.
business due to its low
The most popular digital currency, or cryptocurrency, is Bitcoin, and these types of financial transactions
usage costs.
are not controlled by the central banks of countries, as they are not issued by these institutions. Other
types of cryptocurrency that are currently in existence are Ethereum, Tether and Litecoin, but these are
worth less than Bitcoin due to the smaller amount of the currency in circulation.
Units of the cryptocurrency are generated by users, also known as ‘miners’, who use the power of their
personal computers to process transactions. The ‘reward’ for doing so is that miners receive some of the
transaction fees involved in the process of payments made.
In order that cryptocurrency transactions are processed fairly and are not obtained dishonestly, there is a
technology that sits behind all transactions called blockchain. Effectively, blockchain is a digital record or
ledger that tracks all cryptocurrency transactions, meaning that each unit of the currency can only ever
be used once by one user.
The data behind the cryptocurrency is time-stamped and stored in the blockchain when it is used in
a transaction, and these records cannot be altered by users. This makes cryptocurrency highly secure,
because the way that the data is stored, and the number of bits involved, means that around  billion
combinations would need to be tried in order to fraudulently replicate or fake a unit.
LINK WB

Consolidate your
understanding by
completing Exercise 1,
page 53 in the Workbook.
. Cyber Security
User data is highly valuable and highly sought-after by cyber criminals, and just as thieves operate in
the real world, computer users who wish to steal data are operating within the world wide web. Any
risk posed to a computer system from an internet source is considered a cyber threat. By taking steps
to understand what the potential risks are, people and businesses are able to better protect their
systems and data.
There are various cyber-attacks on our computers and data that users have to protect themselves
ENRICHMENT against. Some of the attacks are against data and are designed to obtain information from
computers and devices, whereas other attacks can be against human users and are designed to
Some cyber criminals
change behaviour in order to obtain information.
have been given jobs by
cyber security companies
because of the skills
that they possess. They
.. Brute-Force Attack
are ethical hackers This type of attack is designed to try and obtain a user’s password without their consent. It is like a
who use their skills to thief taking all available keys (not just yours) and trying them all in a door lock one after the other
identify security flaws until the correct key is found. A brute-force attack is where a computer program floods a system with
and make improvement an enormous number of potential passwords or passcodes and uses trial and error to try and find the
recommendations. Can
password that matches. Brute-force attacks target weak passwords created by users.
you find an example of
a cyber- criminal who
now uses their skills for
good reasons?
.. Data Interception
When data is being transmitted around a network such as the internet, if it is unencrypted it has
the potential to be intercepted on its way to its intended destination. A cyber criminal could use a
piece of software called a packet sniffer to examine packets of data as they make their way around a

72 The Internet and Cyber Security

SB CS PP.indb 72 14.5.21. 14:14


Chapter 5
network. The packet sniffer can then feed the contents back to the criminal, who may be able to use
the information for fraudulent purposes.

.. Distributed Denial of Service (DDoS) Attack REFLECT

The biggest DDoS attack to


A Distributed Denial of Service (DDoS) attack can happen to a website or web server and is designed date took place in February
to cause disruption to website owners. A criminal would use software that can ‘force’ thousands of 2020, after Amazon
innocent computers around the world to send a viewing request to a web server. This unofficial Web Services (AWS) was
network of recruited computers is known as a botnet and would have likely been infected with some targeted. Can you find
form of malware (see .. below). The flooding of requests sent to a server will overload it and either any other high profile
slow the website right down or cause it to go offline altogether. examples of DDoS attacks?

.. Hacking
In simple terms, a hacker is a user who is seeking to gain unauthorised access to a computer system. HELPFUL NOTES
Hackers who are attempting to do this for criminal purposes are referred to as black-hat hackers, and
are usually doing so to access, change or damage the data held on the system being hacked. A black-hat hacker is
aiming to access systems

.. Malicious Code Software (Malware) for criminal purposes,


whereas a white-hat
hacker is doing the
Malware (short for malicious software) are pieces of software that have been written and coded with opposite. Often called
the intention of causing damage to or stealing data from a computer or system. ethical hackers, a white-
There are several different types of malware that criminals have coded and used against users hat hacker will try to find
and systems. security loopholes in a
system and give advice
to the network owners
Type of malware Description about how to close them.

Virus Like a human virus, this type of malware infects a computer


and then replicates itself to be sent to another computer. This
transmission can happen where infected files are shared via hard REFLECT
disk drives or sending online.
The trojan horse malware
Trojan horse A trojan horse is malware that is hidden away in the code of
is named after the Greek
software that appears to be harmless. Criminals will often hide
myth of the same name.
trojan horses in illegal or pirate software to obtain user data.
Worm A worm operates similarly to a virus, however rather than
trying to damage files, it simply replicates itself until the
computer’s resources are used to their maximum capacity and
no further processing can take place, leading to system failure
and crashing.
Spyware Spyware is a piece of malware that behaves a little bit like a
cookie but, instead of benefitting the user, it actually sends data
back to a criminal. Spyware collects information about online
browsing habits without a user knowing.
Adware Adware is not always malicious, but almost always involves
installing processes for displaying pop-up adverts while
browsing websites, and will install tracking cookies, often
without user permission.
Ransomware This type of malware is often quite nasty and makes threats to
users about bad things that will happen to their data unless a
payment of money is made.

The Internet and Cyber Security 73

SB CS PP.indb 73 14.5.21. 14:14


Chapter 5
.. Social Engineering
QUICK CHECK
This form of cyber-crime is where users are manipulated into behaving in a way that they would not
How is social engineering normally do. There are several different forms of social engineering when it comes to cyber-crime,
different from other forms but a physical form of the attack is shouldering, when someone attempts to gain information by
of cyber-crime? looking over your shoulder. This can occur in public places like ATMs or at the cashier when you are
paying for goods. Criminals will attempt to obtain things like Personal Identification Numbers (PINs),
and social engineering is one of the reasons why passwords appear as asterisks onscreen when users
type them in.

.. Pharming
Pharming is a type of social engineering. It is where a user will be sent from a genuine website to
a fake one, with the hope that this goes unnoticed. A user may then be prompted to enter login
details, and this can then be collected by a criminal for use on the genuine site.
Pharming attacks occur when web servers are attacked, and code is inserted into a website that
redirects visitors. These attacks are quite difficult to spot when they occur and require a user to be
vigilant to changes to the URL (for example, how the domain name is spelt) and subtle changes in
the way a site looks.

.. Phishing
Phishing is a form of social engineering which takes place largely through emails. A criminal will
WORD ALERT send an email that looks genuine as if it has come from a business and will often ask a user to click
a link within the email, after an instruction that their data is at risk if they do not comply. Once a
Spoof: something that is user clicks on a link, it often takes them to a spoof website that is designed to try and obtain login
fake but pretends to be details. Phishing emails often look convincing but may contain spelling errors and the URL of the
genuine. link and the sender’s email address are often giveaways that the email is not genuine. Other features
of phishing emails are that users are generally not referred to by name, where a genuine company
usually would do so.

. Solutions to Cyber Security Issues


One of the most important things that a computer user or network manager must do is protect their
systems from the attacks described above. There are a number of ways in which this is possible, and
users must select the most appropriate method(s) of guarding against cyber-crime.

.. Access Levels


WORD ALERT This method of protection is hugely important in organisations where there are lots of users
accessing a network. Users should be assigned different levels of access depending on the role they
Compromise: become have. Administrators of a network have full access and control, and there are several levels of access
vulnerable or function
going down to basic user access which has only limited rights of usage. This method of protection
less effectively.
ensures that user behaviour can be controlled while they use a computer on a network.

.. Anti-Malware, Anti-Spyware and Anti-Virus


DEFINITION
It is essential that networks are regularly protected from harmful or malicious software being
Corrupt: the act of making installed. Such software could potentially compromise security of the network, and may allow
data unreliable by errors criminal activity to occur, including the theft of personal or company data. In extreme cases, such
or alterations. software could also potentially corrupt data in a network to the point that it becomes unreadable –
this type of corruption is called a virus attack.

74 The Internet and Cyber Security

SB CS PP.indb 74 14.5.21. 14:14


Chapter 5
In order to guard against this type of behaviour, a network should have anti-malware and anti-virus
applications installed that protect all devices on the network.
Anti-malware and anti-virus software are constantly scanning documents, files and also incoming
data from the internet. They are designed to detect suspicious activity and files prior to them being
opened or stored and warn the user against opening the files.
WORD ALERT
If the anti-malware or anti-virus software does detect a file or application that is potentially harmful, it
will immediately quarantine that file away from the rest of the network, preventing it from installing Quarantine: to place
or multiplying itself to other areas of the network or hard disk drive. into isolation.
Sophisticated: more
Upon user instructions, the software will then remove and delete the offending malware or complex.
virus. It is important that network managers regularly perform deep file scanning to maintain
the safety of the data that is stored. Users should also be particularly careful when downloading
files and software from the internet and should always check that the downloaded files are from
a reputable source. Additionally, as computer viruses and malware become increasingly more
sophisticated, it becomes vital to update the anti-malware and anti-virus software to the latest ENRICHMENT
versions, including updating their database of known security threats. Refer to section .. on
Can you find out the
automatic software updates.
names of the most recent
viruses that have infected
.. Authentication computers around
the world?
A simple and basic method of data
security is to set a password that is only
known to the user in order to access
secure information.
QUICK CHECK
Passwords can be set on many different
websites or devices; mobile telephones What are the differences
encourage users to set a password between spyware,
to use the device, and common web malware and a virus?
applications require users to create a
password in order to access the features
of the application.
It is vitally important that your passwords are not obtained
by unauthorised users.

Passwords should be strong enough to stop criminals from guessing them or hacking into your
personal accounts or applications. A weak password such as a simple seven-character word can be
cracked by a professional hacker in a fraction of a millisecond. An eight-character password would take
on average five hours to crack and a nine-character password would take around five days to discover.

The Internet and Cyber Security 75

SB CS PP.indb 75 14.5.21. 14:14


Passwords should be strong enough to stop criminals from guessing them or hacking into your
personal accounts or applications. A weak password such as a simple seven-character word can be
cracked by a professional hacker in a fraction of a second. An eight-character password would take
on average five hours to crack and a nine-character password would take around five days.

5
Chapter 5 LINK
PASSWORDS
Some Inapplications
order to make
will not enable you to
passwords
progress beyond the
stronger,
it sign
initial is always
up stage ifadvisable
yourtopassword
use aiscombination
not  characters less than
strong enough. You can  milliseconds
of alpha
check your password(letters) and  characters
numeric
strength characters. If
here: http://  hours
howsecureismypassword.
your password was a
net
string of nine numbers, and then you
added a letter to those numbers, your
password would be strong enough
that it would take somewhere in
WORD ALERT the region of  years to crack the
password. Once you start combining
Alphanumeric: letters alphanumeric characters, upper-case
and numbers. and lower-case letters and special characters
Substitute: exchange for  characters
such as question marks and dollar signs, these are  days
something different. the most secure sorts of password you can set.
One common problem with setting passwords, however, is where users substitute letters in easy
words with similar symbols (see graphic below). Hackers are already aware of this practice and would
LINK still be able to crack theseTocombinations
make your password
withstronger, use a combination
ease. Passwords of alpharandom
that appear (letters) and
arenumeric characters.
the best type, If your
however they do becomepassword was a string of nine numbers, and then you added a letter to those numbers, it would take
less memorable to a user and can be quite easily forgotten or mistyped.
somewhere in the region of  years to crack. The most secure passwords combine alphanumeric
Some applications WORD ALERT characters, capital and lower-case letters and special characters such as question marks and dollar
will not allow you to signs.
Alphanumeric: letters
progress beyond the A common problem with setting passwords, however, is when users substitute letters in easy words
sign-up stage if the
and numbers oK3<jF8$jT8@iO8*
Substitute: exchange for with similar symbols (see the graphic below). Hackers are already aware of this practice and could
password you provided something different easily crack these combinations. Passwords that appear random are best, however they do become
is not strong enough. less memorable, and are easily forgotten or mistyped.
Check your password
strength here: http://
howsecureismypassword. cabbage
Weak undesirable password Medium undesirable password Strong password
net.

Passwords should be changed regularly, however, it is unrealistic for


users to change their passwords every few weeks. It is common
Weak Medium Strong
practice in most organisations for users to change their
Password Password Password
REFLECT
passwords yearly, but the reality is that many users never
Do you use the same change their password to access popular applications from
Passwords should be changed regularly. It is common practice in most organisations for users to
password for multiple the first time they have been
changeset. Other
their examples
passwords of poor
every few months or yearly, but the reality is that many users never change
accounts? How often password security are when users set the same password
their password for some applications. It is also poor password security to use the same password for
have you changed your for most or all of their online
mostaccounts; onceaccounts;
or all your online one account
once one application is compromised, it could then compromise
password? Are you the others.with the same password
is compromised, other accounts
the only person who could potentially be compromised as well.
knows it?
Another way that a user can ensure their passwords are not
18
compromised is to install a piece of anti-spyware software
on their computer. Spyware is software that can be installed
onto a computer without the knowledge of a user, and usually
happens when a user has been careless or has visited an
insecure website.
Biometric authentication is just
Spyware runs in the background of your computer, and often one way of a user authenticating
makes processes slow down deliberately, however some of themselves onto a network.
the more malicious spyware can also track the keys pressed
by a user. The spyware then feeds the information to a criminal using a data collection application
and will gather possible passwords to access private information. Installing a piece of anti-spyware
software will scan regularly for this type of rogue application and remove them.
Passwords are not the only method of authentication that users can undertake to ensure
security of data. Several different methods can be used by websites, businesses, shops and
other transactional devices.

76 The Internet and Cyber Security

SB CS PP.indb 76 14.5.21. 14:14


Chapter 5

Method of authentication Features

Zero login
Zero login is based on the idea that machines
Unusual and devices can detect changes in user
behaviour behaviour, rather than relying on passwords
can trigger a to authenticate activity. An example of this
system to lock is with mobile devices – software detects
a user out.
when and where logins occur and check
with a user that it is a genuine attempt to
access an account. Zero login authentication
builds up a picture of a pattern of behaviours
based on usage of various different devices to
ensure that access to software and systems is
granted to the right user.

Biometric This is where a user’s human features


authentication are used to grant access to devices or
A mobile applications. Common biometric methods of
device scans a authentication include fingerprint matching
user’s face to and retina scanning, and more recently facial
authenticate recognition.
them.

Magnetic stripes Most credit card-sized cards feature a


magnetic stripe on the back of the card. These
Magnetic stripes can contain up to  characters of data
stripe cards about a human, such as a name and account
can be used number, and this data is stored magnetically.
for hotel The card is then ‘swiped’ through a magnetic
door keys. stripe reader and the device is able to
collect the magnetic data from the card
for processing. As long as it matches user
data that is stored, the reading of the stripe
authenticates the user successfully.

Smart cards This type of authentication is most commonly


found in a credit or bank card. The smart
Smart cards
card has a chip that is read when inserted
have been
into an Electronic Funds Transfer Point of
used in
Sale (EFTPOS) device, containing a chip and
banking for
PIN reader. The chip on a card is capable of
many years.
holding a lot of information and, when a user
inserts the card into the device, they also
need to enter a four-digit PIN that will enable
a purchase to take place. The device reads
the information from the chip and, if the PIN
matches the information, the card can be
successfully used. This type of authentication
is called two-factor authentication.

The Internet and Cyber Security 77

SB CS PP.indb 77 14.5.21. 14:14


Chapter 5

Method of authentication Features

These tokens are often found in the


form of a numerical display device.
Physical tokens When a user is required to authenticate
themselves on a network, a one-time
A token can passcode is generated and sent to
be used in the token. As long as a genuine user
conjunction is in possession of the token, they can
with a enter the passcode on a device and
keycode. gain access to a system or network.
The tokens can communicate with
a network server through various
methods, most commonly through a
USB port or Bluetooth.

Similar to physical tokens, electronic


tokens allow users to authenticate
Electronic tokens themselves onto a network or system
using virtual methods. An example of
A user should an electronic token could be an answer
know the to a question that only a genuine user
answer to an would know, or a passcode generated
electronic and sent to a trusted device such as
token a mobile phone. The passcode can
question. then be keyed into a network device in
order to authenticate a genuine user.
Sometimes during authentication, a
system will ask for multiple electronic
tokens, for example a password, PIN,
HELPFUL NOTES confirmation of email address and a
trusted word.
Operating systems are
almost always released
with security ‘bugs’ in
them as the developers
often rush to get software
Activity
out on sale. System For each of the following authentication methods, list the hardware that a system would need in
updates usually occur order for the authentication to work successfully:
immediately when the 1 Physical tokens
user runs an operating
system for the first time. 2 Smart cards
3 Magnetic stripe

.. Automating Software Updates


This type of protection ensures that applications like operating systems, anti-virus and other
commonly used pieces of software are always operating with the latest version installed. Software
developers will often discover problems in their applications after they have been released and
will develop ‘patches’ that will close potential security loopholes. By enabling automatic updates,
these ‘patches’ will be installed routinely without a need for the user to worry and constantly check
for updates.

78 The Internet and Cyber Security

SB CS PP.indb 78 14.5.21. 14:14


Chapter 5
.. Spelling and Tone in Communications
As we learned earlier in section .., phishing emails are a threat to security. However, one thing that
tends to set them apart from other emails is that they tend to have spelling errors and mistakes are
often made by criminals when constructing the emails. As users, if we write our communications
professionally and accurately, the recipient is more likely to believe it is a genuine communication
and respond accordingly.

.. Checking the URL of a Link


Before clicking on any link, whether on a website or in an email, a user should always double check
that it is a genuine link. Usually by hovering over a link, web browsers or email software will enable
you to see the intended destination. If the URL has different words in it other than the name of
the website you expect to visit, or if it is simply an IP address, then the link should be treated with
caution and should not be clicked.

Activity
Can you spot the things in this image that suggest this is a phishing email?

This might be a phishin message and is potentially ussafe. Links and other functionality have been
disabled. Click here to enable functionality (not recommended).
From: PayPal [service@paypal-australia.com.au Sent: Thu // : AM
To: Mr. xyz
Cc:
Subject: Your account has been limited

PayPal
How to restore your Paypal account
Dear PayPal member,
To restore your PayPal account, you’ll need to log in your account.

It’s easy:
. Click the link below to open a secure browser window.
. Confirm that you’re the owner of the account, and then follow the instructions.

PayPal Email ID PP

.. Firewalls
A firewall is a piece of hardware or software that sits between a computer and the internet. Firewalls
carefully look at all incoming and outgoing traffic to a network or a computer. Computer users can
set different rules and criteria for the traffic that the firewall must apply and can be set to block traffic
that doesn’t meet the rules set.

The Internet and Cyber Security 79

SB CS PP.indb 79 14.5.21. 14:14


Chapter 5
Computer users can create a blacklist of websites (websites that cannot be visited) or a whitelist
of websites (a list of the only websites that can be visited) and the firewall will apply these rules to
all network or computer traffic. When the traffic is checked, if it meets the rules or criteria it will be
accepted by the firewall. If the traffic does not meet the rules or criteria that have been set, the
firewall will reject the traffic and halt the data transmission.

.. Privacy Settings


As more online profiles are used to share
content on social media, there is an ever-
increasing need for users to ensure that
their privacy settings are set correctly.
If no privacy settings are set, then
a user’s content is accessible to
anyone using a particular site or
platform. Privacy settings should
be set to ensure that a user has full
control over who sees and interacts
with data and information online.

.. Proxy Servers


One way of keeping website browsing
activity secure is by using a proxy server.
The user will then view web pages through
a proxy server rather than directly via the
home router. The proxy server sends out the
requests to view a website and sends the information
back to the user. This has the advantage of enabling a Privacy settings are vital for protecting
user to keep their IP address secret, thus minimising the against unauthorised access.
opportunities for cyber- criminals to know where data
is being sent to and from. DDoS attacks are therefore much less likely to occur when using a proxy.
Proxy servers can also be used as parental controls on a network, as they can be set up to block
incoming and outgoing web traffic to specified websites.

.. Secure Sockets Layer Security Protocol


SSL is a protocol that is commonly found on websites where financial transactions take place. Any
website that requires users to use a bank card to make a purchase should have secure sockets layer
security. SSL encrypts the connection between the user’s computer and the website that is being
used. All data that is transmitted between the user’s web browser and the web server that hosts
the website is encrypted by the protocol and stays private. The types of data transmitted securely
through the protocol are bank card numbers, login details and passwords.
It is important to check whether a website uses the secure socket layer before carrying out a financial
LINK WB transaction. If a website has got https:// at the start of the URL, then the site is using SSL and is safe
to transmit personal data. If the URL only has http:// at the start, private data is in danger of being
Consolidate your intercepted, and may not be secure.
understanding by
completing Exercise 1, An SSL connection is created between a web browser and a web server. This connection is known
page 54 in the Workbook. as an SSL ‘handshake’, whereby the browser asks the server to identify itself. In order for this
connection to be secure, the web server needs to be certificated. This then provides the appropriate
identification to enable the connection to be made. The encryption information is shared via the
certificate, and the communication then takes place between server and browser, with both pieces
of technology having secured the asymmetrically encrypted connection.

80 The Internet and Cyber Security

SB CS PP.indb 80 14.5.21. 14:14


Chapter 5

The Internet and Cyber Security 81

SB CS PP.indb 81 14.5.21. 14:14


Chapter 5

Let’s Review

1 What is the difference between the internet and the world wide web?
2 What do the letters URL stand for?
3 Http stands for hypertext transfer protocol. What does https mean?
4 Name three features of web browsing software.
5 What do the letters DNS stand for?
 Describe the process of a DNS Query.
 What are the two types of cookies stored when browsing the web.
 Name two things a cookie can do while you are browsing the web.
 Bitcoin is one type of digital currency. Name another two types.
10 Explain what blockchain is in terms of digital currency.
 Name three different types of cyber-attack that could occur.
 What is malware?
 What is the difference between pharming and phishing?
 Explain what social engineering is.
 Explain how enabling software updates can protect user data.
 What does a proxy server do?

82 The Internet and Cyber Security

SB CS PP.indb 82 14.5.21. 14:14


CHAPTER Automated and
6 Emerging
Technologies

COMPUTER SCIENCE WATCH

Scan the page to watch a clip on emerging


technologies in computer science.
Before watching discuss what you expect
to see or hear.

QUESTIONS

• What are the newest technologies coming


into our lives?
• What is an automated system?
At the end of this chapter, you will be able to: • What is a robot?
explain how sensors, microprocessors and actuators work together to • How can artificial intelligence change
our lives?
create automated systems
the advantages and disadvantages of using automated systems in
different scenarios
explain what is meant by robotics, including the common characteristics of
a robot
understand the role of robots in different areas of society and the
advantages and disadvantages of this
explain what is meant by artificial intelligence, including the main
characteristics of artificial intelligence and their basic operation

83

SB CS PP.indb 83 14.5.21. 14:14


Chapter 6
As technologically advances there is less need for humans to carry out some jobs, especially
repetitive tasks. Computers created for specific purposes can automate this type of work, leaving
WORD ALERT
humans to ensure that nothing goes wrong with the automated processes. This chapter will explore
Automated: machines some of the new ways that computer science has helped to enhance the way we work and live.
carrying out a job that
would otherwise have
been done by humans.
. Automated Systems
For a system to be fully automated and operate independently of a human, it combines several
QUICK CHECK
different component parts. The three important components of an automated system are:
Do you use any • sensors
automated systems? • a microprocessor
Do you operate them • actuators
yourself?
A temperature
sensor attached
to a water pipe.

A microprocessor
embedded into a
machine.

An actuator, in
the form of a
piston carrying
out a physical
movement.

84 Automated and Emerging Technologies

SB CS PP.indb 84 14.5.21. 14:14


Chapter 6
Most sensors are based upon changes in
the environment. For example, a motion
sensor measures change in heat. The sensor LINK
detects the change and sends a message to a
microprocessor (see Chapter  Hardware) to See Chapter 3 Hardware.
do something different. The microprocessor
uses the input from the sensors and sends
instructions to other components, such as DEFINITION
actuators.
Actuators turn electrical signals into Components: pieces of
physical outputs such as movements. equipment in a system.
When all three of these components work
together, automatic instructions become
movements. These movements may be repeated WORD ALERT
infinitely, depending on the objective of the A motion sensor used in the home.
automated system. Infinitely: continues
forever, until stopped.
A microprocessor works mainly on the basis of data comparison. If the data returned by a sensor is
greater, or less than data that is stored, a signal is then sent to an actuator to perform an action.
The action will only stop being carried out when data has normalised and matches again, or after
an amount of time has elapsed.
Automated systems exist in many different industries and situations (see Figure .).

Gaming
Lighting
Artificial intelligence
Home control systems
opponents in games

Weather
Science
Airport weather
Laboratory automation
monitoring systems

Industry
Agriculture
Packaging of items to be
Crop harvesting
shipped

Figure . Automated systems.

Table . explores some features of these automated systems and the advantages and disadvantages
of automation for different industries and situations.

Situation Scenario Advantages Disadvantages

Industry Items in a factory are packed Production is much Fewer job


and packaged by an automated faster and the opportunities
production line. Sensors are number of errors are as humans are
used to detect the sizes of items, reduced. replaced by
microprocessors ensure that the machinery.
correct packaging materials are
selected and actuators are used to
move the items around to ensure
consistent and accurate packaging
each time.

Automated and Emerging Technologies 85

SB CS PP.indb 85 14.5.21. 14:14


Chapter 6
Situation Scenario Advantages Disadvantages

Transport Driverless cars can transport goods A huge reduction Potential for more
and passengers around a city based in road traffic vehicles on the road
LINK WB on start and end point instructions. accidents and if the technology is
Consolidate your Sensors detect the vehicle proximity injuries caused by popular.
understanding by to other objects; microprocessors collisions. Automated cars are
completing Exercise 1, control factors like speed and Less traffic very expensive.
page 58 in the Workbook. direction, and actuators are used to congestion.
move the steering mechanism.
Agriculture Automatic harvesting of crops for Faster collection of Automated vehicles
supplying to shops and supermarkets. the goods. are large and
Sensors detect optimal times for Able to cover a large expensive.
harvesting based on factors such as distance in a short Reduced job
weather conditions, microprocessors amount of time. opportunities for
determine exact locations for the harvest humans.
and actuators are used to carry out the
extraction of the goods from the ground.
Weather Automated monitoring of weather at Information about Predictions can
airports to help predict poor flying and the overhead sometimes be
landing conditions. Sensors check for weather conditions incorrect, for
potentially dangerous weather such as is fed constantly to example if snow is
wind, rain, fog or snow, microprocessors air traffic controllers. forecast and does
ENRICHMENT are programmed to issue relevant not arrive.
warnings as a result of the data
Can you think of any gathered and actuators can activate
other situations where an
emergency systems such as lighting
automated system has
replaced the work of a
wherever required.
human? Gaming The introduction of artificial intelligence The depth of Decreases real
as opponents in computer games gaming challenge social interactions
(see section .). Sensors are built is increased with other humans
into gaming environments where with computer- and can create an
characters interact with human generated almost fictional life.
controllers, microprocessors determine opponents who
game outcomes and decisions, and behave in a ‘human’
actuators are activated in controllers to way.
give haptic feedback, such as vibrations.
Lighting Lighting control systems in a house Systems can be Systems can
where routines can be preset based ‘taught’ to react become complex
on behaviours. Sensors can detect to environmental as they are different
ambient light levels, microprocessors factors, such as from traditional
run routines based on human switching lights switches. The
requirements and actuators can on and off when lightbulbs and
activate home equipment. the conditions are technology
correct. also tend to be
expensive to
maintain.
Science Automated laboratory experiments Many more If something goes
that can be carried out continuously repetitions of wrong it can be
over many days. Sensors detect experiments and several hours before
changes in environmental conditions, reading of data can this is discovered,
microprocessors can calculate required take place than which could
alterations to the experimental settings when humans carry ruin any results
and actuators can turn on heaters, out tests manually. collected.
coolers or water supplies as required.

86 Automated and Emerging Technologies

SB CS PP.indb 86 14.5.21. 14:14


Chapter 6

. Robotics
The term ‘robotics’ means the design, construction and operation of
robots that are used to enhance our working and personal lives.
The different types of robots include those used in factories
on production lines, domestic robots used in and around
the home and airborne robots such as drones.
To be classified as a robot, a system should have the
following characteristics:
• A mechanical structure or framework: a robot
should be a piece of machinery that usually has some
movable parts. It can be large or small.
• Electrical components: a robot should have a
combination of sensors, a microprocessor and actuators. The
robot should also be able to be programmed by a human to carry A drone is a popular
out various tasks in a repetitive fashion until complete. type of robot.
The use of robots is increasing all the time, and there are several scenarios where human jobs have
been replaced by robotic equivalents (Figure .).

Domestic
Robotic vacuum cleaners Entertainment
and lawnmowers will Robotic cameras are used to
carry out the jobs with position viewing angles.
no human input.

Medicine
Use of robots to assist in Industry
surgeries where human Manufacturing Robots
hands are unable to carrying out tasks like
reach. welding.

Transport
Agriculture Robots used in space exploration,
Robots are used to apply for example the Mars rover.
fertiliser and pesticides
to crops.
ENRICHMENT

Can you think of any other


Figure . Robotics. situations where a robot
has replaced the work of a
human?
Table . explores
some of the features
of robotics for different
industries and situations.
Rand the advantages
and disadvantages of
robots.

Robotic arms operating


in a car manufacturing
factory.

87

SB CS PP.indb 87 14.5.21. 14:14


Chapter 6
Situation Scenario Advantages Disadvantages

Industry Manufacturing robots on a Accuracy in production Fewer job


production line in a factory, is vital, and robots ensure opportunities as
LINK WB putting together cars. that every car is put humans are replaced
together the same way by machinery.
Consolidate your and is identical to all of
understanding by the other cars produced.
completing Exercise 1,
Transport The introduction of robots Robotic vehicles can get The priority of the
page 61 in the Workbook.
into the transport industry to places humans are algorithm could be
may soon mean that we unable to. different in each car.
have access to self-driving Some may prioritise
cars. Space exploration the safety of the driver,
has increased by sending some pay priorities the
robotic vehicles such as safety of pedestrians etc.
the Mars Rover to other This could cause ethical
planets. issues. Automated
technology is expensive,
and could also replace
human jobs.
Agriculture Crops can be given exact Accuracy of delivery of Fewer job opportunities
amounts of fertiliser and the chemicals is very as humans are
pesticide by robots. This is important to the success increasingly replaced by
particularly useful when the of farming and crops. machinery. The robots
chemicals are potentially can also be expensive.
hazardous to humans.
Medicine Robots can be used during Surgery can take less This technology is
surgeries to perform complex time, which improves the highly expensive
procedures with more chances of recovery for and has to be tested
precision, flexibility and the patient. extensively in research
control. They can also be before it is used on
used to monitor vital life data, humans.
in research and development
such as tissue engineering,
in the replacement of limbs
such as bionic prosthetics
and to simulate certain
medical environments and
tasks for training purposes.
Domestic Traditional household Robots can quickly ‘learn’ This can encourage
appliances like vacuum the environment. They a more sedentary
cleaners and lawnmowers can be programmed to lifestyle in humans.
are being replaced by work at convenient times.
robotic versions.
Entertainment Robots such as drones Film can be presented in Fewer job opportunities
REFLECT
can be used for film and ways that a human would as humans are
television programmes, for not be able to normally see increasingly replaced
Where have you come example with aerial shots. due to robotic technology. by machinery.
across AI systems?

ENRICHMENT
. Artificial Intelligence
Virtual reality (VR) is Artificial intelligence (AI) is a computer system that thinks like a human, or that simulates human
another emerging intelligence.
technology that is
What sets AI apart from other forms of computer programming is that the system collects enormous
changing the way we live
our lives. Have you ever
amounts of data from its environment. This data collection is based upon some very specific rules.
experienced a VR world? The system then uses this data alongside the rules and can reason with it, using ‘what-if’ questions.
An AI system can then learn and change their output by analysing the data constantly.
The two types of AI system you should be aware of are expert systems and machine learning.

88 Automated and Emerging Technologies

SB CS PP.indb 88 14.5.21. 14:14


Chapter 6
.. Expert Systems
IT applications and systems are sometimes designed with expert procedures and the expertise of QUICK CHECK
professionals in mind. The systems are designed to imitate a human expert on a specific topic, as if
An expert system is any
that person was actually present. These applications often have to be reasonably portable to be used
system that replicates
in the field of expertise. the decisions taken by
a human expert. Expert
Chess games systems have to be
As chess is a highly bespoke to particular
strategic game, developers circumstances.
have designed a system that
allows a human user to play
against a computer. Financial
The computer 'learns' moves planning
and uses its database to play Primarily used by financial
against an opponent. advisors, planning systems can help
to project savings and investments
depending on circumstances.
Medical diagnosis The system can suggest ways
As with patient data, medical of saving money or calculate
professionals often call on IT to expenses such as tax based on
help diagnose difficult illnesses. information given.
Systems will pose questions that
doctors can use to narrow down
symptoms and make a
Car engine
diagnosis.
fault systems
Used if a car goes wrong
and the solution to fix it is not
immediately obvious.
Route scheduling for
A computer is plugged into a
delivery vehicles
Mineral prospecting special socket of a car and the
system will then use the fault This is a system used by delivery companies
A system which uses sensors to ensure its vehicles make the most efficient
system to diagnose the
and probes in an area. journeys and ensure cost effectiveness.
problem.
The system calculates the probability The system will look at the number of parcels to
of rocks and minerals being present be delivered, the number of delivery points, the
in the area being explored. size of the vehicle and time available, and will
calculate the optimum route.
Plant and aminal
identification
Expert systems for classifying animals
and plants exist, based on a number
of questions that are mainly 'yes' and
'no' or factual answers.

WB LINK

Table . describes the features of expert systems. Consolidate your


understanding by
Expert System Feature Characteristics completing Exercise 1,
page 63 in the Workbook.
User interface How a user communicates and interacts with the expert system. The
system will often ask questions that require an answer or a button press.
Inference engine The part of the system that draws upon information from the
DEFINITION
knowledge and rules base to produce possible solutions to a problem.
Knowledge base A collection of information from subject experts. Logical reasoning: a set of
Rules base A set of rules that are unable to be broken during problem solving. reasonable conclusions
and explanations.
Explanation system The logical reasoning behind the solutions and decisions offered.

Automated and Emerging Technologies 89

SB CS PP.indb 89 14.5.21. 14:14


Chapter 6
When an expert system is implemented and used, the user of the system would firstly interact with
the interface. This would be through the answering of questions that would form decisions leading
to further questions, a little bit like a tree diagram. Throughout this, the rules base would prevent the
user from breaking any rules of the system. This is important for safety. The system would use the
answers that were being given to utilise the inference engine. This would begin generating potential
solutions. If the answers generated do not automatically produce an obvious solution, the knowledge
base would enable the user to refer to related information from experts that may potentially provide
WORD ALERT
a solution. Once a suitable solution has been generated by the expert system, there would then be a
Replicating: creating logical explanation to accompany the solution to enable the reasoning behind the results.
as close to a copy of
something as possible.
.. Machine Learning
Machine learning is a form of AI that allows a computer to perform tasks intelligently and efficiently
REFLECT
by learning from examples.
Think of types of system The system is programmed with an ability to learn or be trained. This happens by inputting data that
that work like a human can be recalled by the system during development: the more data the system receives, the better it
brain? will be at recognising things later.
Computer scientists program systems for machine learning by replicating some of the functions of
the human brain, such as the nervous system. By producing a system that is as close to a human
HELPFUL NOTES brain as possible, this ensures that it can begin to react, adapt and change its responses based on
the input it receives.
The world chess
champion at the time
One of the most famous AI computers was called Deep Blue – a computer that could play games of
was Gary Kasparov chess against humans. In , Deep Blue was the first computer system to beat the world champion
from Russia, and he did chess player, within the same time limits as a normal game. Although Deep Blue was not quite the
manage to beat Deep type of machine learning that we see today, due to restrictions on storage capacity, it paved the way
Blue eventually! for much more complex systems as the technology evolved.
A current example of machine learning is where computers are able to suggest tagged names of
people on social media based on the amount of times their previously tagged photographs appear
in timelines. The same process happens with places too, and machine learning AI on social media
uses previously learned input to suggest place locations to add to photographs.

A supercomputer capable of machine learning has enormous processing power.

90

SB CS PP.indb 90 14.5.21. 14:15


Chapter 6

Let’s Map It

Sensors Microprocessor

Decisions made Processing

AUTOMATED
instructions sent

SYSTEMS
Automated system

Activaters
Movements

Science Industry Transport Agriculture

Weather Gaming Lighting

ROBOTICS

• Industrial • Medicine
• Transport • Domestic
• Agriculture • Entertainment

COMPUTERS ARTIFICIAL
THAT LEARN INTELLIGENCE
Chess your
move...
Expert system Machine learning

Automated and Emerging Technologies 91

SB CS PP.indb 91 14.5.21. 14:15


Chapter 6

Let’s Review

1. What are the three components of an automated system?


2. What does an actuator do?
3. Apart from driverless cars, describe an example of an automated system that exists in the world
of transport.
4. A disadvantage of automated systems in gaming are that they can reduce social interactions
with other humans. Think of another disadvantage?
5. Name a type of robot.
6. What are the characteristics of a robot?
7. Robots are sometimes used for medical purposes during operations. Think of another example of
a robot used in medicine?
8. An advantage of a robot for domestic or home use is that they carry out jobs accurately. Think of
another advantage?
9. What do the letters AI stand for?
10. What are the two types of AI?
11. In your own words, and using the vocabulary knowledge base, rule base, inference engine and
interface, describe how translation software works.

92 Automated and Emerging Technologies

SB CS PP.indb 92 14.5.21. 14:15


CHAPTER
Algorithm Design
7 and Problem Solving

COMPUTER SCIENCE WATCH

Scan the page to watch a clip on


algorithms.
Before watching discuss what you expect
to see or hear.

QUESTIONS

• How is a problem solved through


programming?
• What stages does a problem go through to
At the end of this chapter, you will be able to: become a solution?
• What are algorithms?
understand the different stages of the program development cycle,
• How can algorithms help developers to
including the tasks performed at each stage create programs?
explain the purpose of a given algorithm
understand how a linear search and a bubble sort are performed
understand how totalling, counting and finding values are performed
understand the importance of validation checks, including how a
range of different validation checks are used
understand the importance of verification checks, including visual
checks and double entry checks
understand how to choose suitable test data to test an algorithm
understand how to complete a trace table
write, amend and identify errors in an algorithm for a given problem
or scenario

93

SB CS PP.indb 93 14.5.21. 14:15


Chapter 7
For the purposes of exemplification of coding, the programming language selected is Python.
There are a few examples where an alternative language has been used to give an example
and, where this is different from Python, this has been stated. The reasons for the differences is
that some of the examples in the IGCSE syllabus are not present within Python, so alternative
languages have been used to demonstrate these features. Python does not deal with arrays or
case statements and, in their place, the list and nested if functions are used instead.
WORD ALERT

Algorithm: a set of rules In this chapter we are going to explore algorithms and how they are used by programmers – in
or instructions for solving particular to solve problems. It is important to understand why algorithms are important, so that
a problem. they can be used for different ways of solving a problem, and also how to structure them correctly.
However, we must begin by looking at the program development life cycle and the process
programmers go through when creating a solution to a new problem.

. The Program Development Life Cycle


When creating any new program, developers follow a process called the program development life
cycle. This consists of four stages: analysis, design, coding and testing.

ENRICHMENT

Do you think critical


thinking skills are
important for asking the
client the right questions
and gathering maximum
details?

WORD ALERT
It is a cycle and not a linear process because after developing the software it is often necessary to go
Perspective: a particular back to the start of the process again if something has been discovered during development.
way of thinking about
something.
UnPC: an exhaustive
discussion to solve
.. Analysis
problems or generate
ideas. Stage  Analysis
Negotiations: a A system process begins with analysing or understanding requirements from the client’s
discussion to produce a
perspective. Here, the client can be an organisation or the end user. The analysis stage may include
settlement or agreement.
several UnPC sessions, negotiations, data collection and information exchange. It is very important
to allocate time to this – without a thorough understanding of the client’s requirements the entire
process can become endless repetitions and corrections.

Stage  Requirements
Ideally, after the initial discussions an analyst will sketch out the requirements. This may not always
be practical if the program managers have limited resources and certain strengths and weaknesses
in their team. To make the tasks achievable and avoid any potential risks and doubts, it is always
good practice in the system process to conduct a feasibility study and create a feasibility study
report. This highlights problems and possible solutions.

94 Algorithm Design and Problem Solving

SB CS PP.indb 94 14.5.21. 14:15


Chapter 7
Stage  Abstraction and Decomposition
The next stage of the analysis is to carry out abstraction and decomposition of the requirements.
DEFINITION
These are of two of the key elements of computational thinking – breaking down a complicated
problem and developing a potential solution to it. Abstraction is the process of selecting the Computational thinking:
information in a problem and focusing only on the important parts of that information. During breaking down a problem
abstraction, any detail that is irrelevant to the problem is ignored. into smaller sub-problems
Decomposition is breaking down a complex problem into small manageable pieces. A problem to solve them.
becomes a series of small tasks that can be handled first individually and then collectively as part
of the bigger program.

Worked Example
Abstraction
Problem: A person wishes to make a cup of tea.
Information obtained: teabags, milk, sugar, white mug, water, kettle, teapot.
Abstracted information: we can ignore the colour of the mug as this is not relevant to this
particular problem.

Worked Example
Decomposition
Problem: A person wishes to make a cup of tea.
This complex problem can be broken down into four smaller problems: water, combine,
personalise and serve.
Decomposed problem:
• Water: fill the kettle with water and heat it until it reaches boiling point.
• Combine: add the water to a teabag in either a teapot or mug and leave for a set time.
• Personalise: remove teabag from water, pour tea into a mug, and add the sugar and milk
to taste.
• Serve: stir the tea and drink it from the mug.

.. Design
In the design phase, the developers of the program will continue the decomposition phase from the WORD ALERT
analysis and begin to draw up visuals of the end product. This will include structure diagrams that
help to visualise the end goal. The coding required to make the visual representations happen will Visualise: to be able to
be started at this point. see a prototype of an idea.
The developers will create flowcharts that show how a program’s decomposed parts will run,
including any decisions or inputs that are needed. The programmers will then begin to develop
pseudocode that enables the complex problems and instructions to be read in plain English.
WB LINK
Pseudocode is an excellent way to check that the instructions make sense prior to the
coding process. Consolidate your
understanding by
completing Exercise 1,
page 66 in the Workbook.

Algorithm Design and Problem Solving 95

SB CS PP.indb 95 14.5.21. 14:15


Chapter 7
Worked Example
Flowcharts
Problem: Making a cup of tea – the water stage.
A flowchart for this particular decomposed problem might look like this.

NO

HELPFUL NOTES

A test plan includes:


YES
• a list of the tests planned
• the data to be used in
the test
• the expected outcomes The steps are written out and the appropriate decisions are contained within the flow.
• the purpose of each test
• the type of tests to be
performed
.. Coding and iterative testing
This is sometimes known as the implementation stage. The programmers work on the design
WORD ALERT modules, such as input, output and processes, and write the code to make each part of the program
functional. The programming is then linked together as a complete solution. A testing strategy is
Comprise: include, be planned by analysts and the test plan will comprise details of all the programs to be tested.
made up of.

.. Testing
DEFINITION Testing every part of the programming requires a test strategy. First, the entire system is divided into
small sections that are tested for input, output and validation rules. Test data is used for all of the tests
Test strategy: test plans for to be carried out. Testing each part of the code individually is known as unit testing, and integration
testing the system. testing is used when this code is all combined to form a program. The testing team reports any errors
to the programmers and the testing is repeated until there are no errors found in the system.

96 Algorithm Design and Problem Solving

SB CS PP.indb 96 14.5.21. 14:15


Chapter 7

. Computer Systems LINK

As we learned in Chapter , all computer systems require an input, some processing and an output. Chapter 3: Hardware.
Also linked to this processing is storage, which enables data to be used as and when required.
All computer systems that operate are made up of subsystems, which can have further subsystems
within them. These are smaller processes that are vital for the bigger system. QUICK CHECK
We can apply what we know about systems to programs. Each problem to be solved by a program
What are the three ways
can also be decomposed into its component parts. For every problem, the design stage must designers can plan a
consider the inputs required, the processing required and the resultant outputs. solution to a problem?
Programmers can employ a combination of different methods to plan solutions to problems.
Pseudocode, structure diagrams and flowcharts are often used in combination to design
these solutions.

Flowchart Pseudocode Structure diagram

Pour the water into the kettle.


Plug the kettle in.
Switch the plug on at the wall.
Turn the kettle on.
Check to see if the water is boiling.
If the water isn’t boiling,
check the electricity.
If the water is boiling, wait for
a number of seconds.
If the water has not yet reached
boiling point, keep waiting.
If the water has reached boiling point,
turn off the kettle and pour the water.

NO

YES

Algorithm Design and Problem Solving 97

SB CS PP.indb 97 14.5.21. 14:15


Chapter 7
.. Flowcharts
In a flowchart, a set of standard symbols are used to identify different parts of the data flow. The most
common symbols are shown here.

Symbol example Use

ENRICHMENT This symbol represents the


start and end points of a
Draw a flowchart for a sequence of data.
simple procedure, for Terminator
example how to brush
your teeth?

This symbol represents an


instruction.

Process

This symbol represents a


decision, that is a yes or no
answer.

Decision

This symbol represents an


input received or an output
sent by a system.
Input or output

This symbol represents


connections between the
other symbols and the flow
of data around the system.
Flow direction

This symbol represents a


smaller procedure running
within the larger program.

Subroutine

DEFINITION .. Pseudocode


Pseudocode: a version Another way that data flow can be represented at the design stage is by using pseudocode. This is
of programmable code a useful way of designing solutions as it can be written in a way that doesn’t require exact use of the
written in standard same syntax as any particular programming language.
English.
Pseudocode at this stage doesn’t rely on which language the program is to be written in and can be
structured in a way that anyone can understand the procedure or flow of data.

98 Algorithm Design and Problem Solving

SB CS PP.indb 98 14.5.21. 14:15


Chapter 7
For example, writing some pseudocode for a procedure for starting a new game might look like this:

IF Lives = 0 REFLECT
THEN
Try writing some
End Game pseudocode to describe
Output “Game Over!” your decisions about
eating.
ELSE restart the level
ENDIF

WB LINK
.. Structure Diagrams Consolidate your
understanding by
Structure diagrams are another way of representing data flow in diagram form. They are different
completing Exercise 4,
from flowcharts as they display the different levels of detail within a set of decomposed problems. page 74 in the Workbook.
The problems are sometimes broken down into smaller problems, or subsystems, and they are
represented in a tree diagram, with the big picture at the top.
In our tea making example, the structure diagram may look like this:

As all of these subsystems happen one after another, this diagram does not have a hierarchical
structure, however if these subsystems were decomposed even further, then there may be another
level or levels of structure.
Just like flow charts, there are a set of pre-defined symbols that go into a structure diagram.

Symbol example Use

This symbol represents an


instruction and will need to be
programmed.
Process

This symbol represents that some


sort of iteration is occurring and
will need to be coded as such.
Loop

Algorithm Design and Problem Solving 99

SB CS PP.indb 99 14.5.21. 14:15


Chapter 7
Symbol example Use

This symbol represents a


common procedure that is likely
to already exist in a programming
language’s library.
Selection

This symbol represents a


selection and that there will be
different outcomes.
Pre-defined function
REFLECT

Think about the last


algorithm you followed,
what was the end goal? . Algorithms
An algorithm is a set of instructions or rules to follow step-by-step to solve a problem. A flat-pack
piece of furniture usually comes with an instruction manual that details a set order on how to
WORD ALERT
assemble the item. This is a type of algorithm.
Pictorially: in the form of As we learned earlier in the chapter, an algorithm can be represented both pictorially and in textual
a diagram. form. There are often multiple ways of solving a problem and exploring all of these at the design
stage is beneficial.
When designing an algorithm, have the end result in mind. A programmer needs to understand the
goal and look at the stages involved in achieving that goal.
• Inputs: What are the inputs to the problem?
• Outputs: What will the outputs look like?
• Order: In what order do things need to be carried out?
• Decisions: What decisions will be made while solving the problem?
• Repetition: Are any of the stages repeated?

HELPFUL NOTES
Worked Example
When designing an Algorithm design
algorithm, always consider
An end user needs a program that calculates shipping costs for items sold, and different costs
the extent of the problem
and the end result.
apply depending on where things are being posted to. The end goal is the correct
posting costs.
The stages of the problem are as follows:
ENRICHMENT • sizes of the items
• cost of preparing the item for posting
It is important to
remember that flowcharts • location of posting destination
and pseudocode have • cost of posting calculated: size + packaging + destination rate
to be used together to
design an algorithm.
A programmer would take all this information, abstract and decompose the problem, and then
Solutions can be unclear if create appropriate flow charts, pseudocode and structure diagrams to come up with the most
either are missing. efficient solution based on the information gathered.

100 Algorithm Design and Problem Solving

SB CS PP.indb 100 14.5.21. 14:15


Chapter 7

Activity
Design an algorithm that helps a bus or train system determine the correct fare to charge a WB LINK
passenger. (Hint, passengers could be adults or concession fares, children or senior citizens).
Draw a flowchart and write some pseudocode to show your working. Consolidate your
understanding by
completing the Exercises
1-3 from pages 66-73 in
the Workbook.

. Solution Methods


The concept of algorithmic thinking has been around for a long time, since computers have
existed. So, there have been many algorithms designed that have become common in a variety of
programming languages. In particular, algorithms can search and sort data, find totals and count
data, and also carry out functional operations such as finding the maximum, minimum and
average values.

.. Linear Search


As its name suggests, this type of search means that all items of data in a set are looked at until
the program matches the piece of data it is looking for. Once this match is obtained, the search is
completed.
We can try to understand linear search by looking at this table of game scores.

REFLECT
Position         
Linear searches are quite
Scores          inefficient in nature. Why
do you think this is the
case?
If a program was required to search for a specific score of , a linear search would begin at position
, and check the score. This score is  and is not a match, so the search moves on to position 
(no match), then position  (no match), position  (no match) and then reaches position , where a
match for  is found. The linear search then ends. ENRICHMENT

This type of search is not the most efficient method of finding a match of data, however it will work A bubble sort is only
on any data set. efficient with a small data
set. How would you sort a
larger data set?
.. Bubble Sort
A bubble sort is another standard solution algorithm, and this is used for turning a data set from an
WORD ALERT
unordered set into an ordered one.
A bubble sort is based upon the idea of swapping adjacent items in a data set until the set is in Adjacent: the item next
the desired order. A bubble sort becomes increasingly slow as the number of items in the data set to another item.
increases, as it is based upon making comparisons. Comparisons: checking
Each time a comparison is run through the data set, this is known as a pass. The sort ends when a one item against another
and looking for differences
pass is made through the data and no swaps are carried out.
or similarities.

Algorithm Design and Problem Solving 101

SB CS PP.indb 101 14.5.21. 14:15


Chapter 7
Worked Example
A bubble sort
A data set consists of the following unordered game scores, and an algorithm is required to
order this list from smallest to largest:

Position    

Scores    

Pass one
The value contained in position  () is smaller than position  (), so nothing changes at this
stage of the pass. The sort moves to the next adjacent position. This time the value in position
 () is larger than position  (), so these two items are swapped.

Position    

Scores    

The next position, position  is considered. The value here () is larger than the value in
position  (), and so these two items are swapped.

Position    

Scores    

This is the end of the first pass, but the order still may not be correct.

Pass two
A second pass now takes place. The value in item  () is larger than the value of item  () so
these are swapped.

Position    

Scores    

The value in position  () is larger than position  (), so these are also swapped.

Position    

Scores    

The value of position  is smaller than position , so no further swaps are made. This is the end
of pass two.

Pass three
The sort then begins a third pass. The value in position  () is larger than position  (), so
these items are swapped.

102 Algorithm Design and Problem Solving

SB CS PP.indb 102 14.5.21. 14:15


Chapter 7

Position    
QUICK CHECK
Scores    
What is meant by a pass
Position  is smaller than position , so no swap is made. Position  is smaller than position , so when sorting?
again no swap is made. This is the end of pass three.

Pass four
A fourth pass is then carried out, but no further swaps are required. This is the end of the sort,
and because no swaps occurred in the fourth pass, the algorithm now knows that the data set is
in the desired order.
As you can see in this example, a bubble sort on a large data set would take a comparatively
long time to carry out and would be highly inefficient.

Activity
How many passes would be required to sort the following data set from smallest to largest using a
bubble sort?

Position     

Scores     

.. Totalling and Counting REFLECT


• Totalling: a common algorithm used to add one number to an existing stored number. For Why is a final pass carried
example, you might wish to add up the number of different objects collected by a player in out in a bubble sort even
a game. when nothing changes?
• Counting: keeping a check on how many times a program has repeated a procedure in a loop.
For example, you might wish to count the number of attempts at a level in a game.
HELPFUL NOTES

.. Standard methods of solution A count is a fairly standard


feature of most computer
There are also some common functions that can be performed as algorithms. This may be useful games. Counting is used
during the problem-solving process. for lives, levels and health.
• MAXIMUM: Within a specific data set, this standard algorithm can identify and return the largest
number in the set.
• MINIMUM: Within a specific data set, this standard algorithm can identify and return the smallest ENRICHMENT
number in the set.
• AVERAGE: Within a specific data set, this standard algorithm can take all the values in the data set Can you find any other
common functions in
and return an average value of all data.
programming languages?

Algorithm Design and Problem Solving 103

SB CS PP.indb 103 14.5.21. 14:15


Chapter 7

HELPFUL NOTES
. Data Validation and Verification
Data validation checks When creating coding for a new system, it is important that a programmer considers all the input of
include presence, data that will be coming into the program. Validation checks on data are therefore essential to the
range, length, format, correct working of the program, and these checks ensure inputted data follow the rules. If the data
consistency and type. does not follow the rules set by the checks, the data will be rejected by the program.

DEFINITION
.. Validation
There are several types of validation check that a programmer can implement into their code
Validation: the process where user input is required.
that helps the system
know the data entered Type of
is correct. validation Purpose Example usage Coded example
Validation check: testing
Range check This checks for data A date of birth is if age in range (0,12):
for validations.
input that falls within required and the print( “you are not old enough
a range, and can program requires a to continue”)
apply to numbers, user to be older than else:
ENRICHMENT dates and characters. age . print(“you may continue”)
Length This checks whether A password or pw = input(“Type your
Validation checks check an input is too long passcode is required password:”
sometimes display a or too short. and must be a if (len(pw)<5 or len(pw)>10):
message known as a particular length. print(“Your password is not
prompt box to let the valid”)
user know the data else:
entered is not valid. print(“Your password is the
correct length”)
Type check This checks whether An age is required type(object)
an input is the in numbers and any
REFLECT
correct type of data, other type of data is
such as text or a rejected.
Different form fields can
number.
have different validation
checks based on the Presence This checks whether The quantity of quant = input(“Please enter
type of data entered. Can check an input has been items ordered was number of required items:”)
you suggest a validation made or not, and will required to make while len(quant) == 0:
check for entering an not allow a process a stock system quant = input(“Please
to continue until calculate a total. enter number of required
appropriate password?
something has been items:”)
entered.
Format This checks to see A date is required day = input(“Please enter the
QUICK CHECK check if data has been in DD/MM/YYYY day of your date of birth:”)
entered in the format. if day in range (1,31)
correct format for print(“next”)
List the different data
the input. else:
validation checks.
print(“please re-enter the
day”)
repeat for month and year
Check digit This checks for A number from a num1 = input(“please enter
the final digit in a barcode needs to be number 1:”)
code of numbers stored. num2 = input(“please enter
and is calculated number 2:”)
mathematically from num3 = input(“please enter
all of the other digits number 3:”)
in the code. sum = float(num1)+float(num2)
+float(num3)
print(“Digit is” (sum))

104 Algorithm Design and Problem Solving

SB CS PP.indb 104 14.5.21. 14:15


Chapter 7
.. Verification REFLECT
It is one thing having a system validate data for input errors, but it is another thing checking to see if
the data entered is meaningful and correct. Even with a variety of the validation rules applied from Visual checks have to be
the table above, wrong data could still be entered. carried out by humans,
and this increases the cost
There are two methods of verifying data that has been entered: of this part of verification
• Double entry: The same data is entered twice and the first entry is checked against the second
one. For example, a system requires a password and asks the user to enter it a second time to
ensure it is an absolute match.
• Visual check: A human check for erroneous data that has been entered into a system and trying
to spot obvious errors or mistyping.

. Testing
Testing every part of the program requires a test strategy. First, the entire program is divided into
procedures that are tested for input, output and validation rules. The testing analysts report any
errors to the programmers and the testing is repeated until there are no errors found in the system.
There are four types of testing data:
• normal data
• extreme data
• abnormal data
• boundary data
Consider the following scenario. The qualifying age for an exam is between  and  years.
The different types of testing values for this are shown in the table.

Type of testing data Description Example

Normal data The data that is entered normally as The values will be , , , , ,
per the expected outcomes. , , .
Extreme data This data includes the extreme The values will be , .
values of the normal range given.
Abnormal data This data is outside the limits of the The values will be , , male,
acceptable data given. female.
Boundary data This data includes the extreme The values will be , , and the
values of the normal range given rejected boundary data would be
and the corresponding smallest/  and .
largest rejected value.

. Trace Tables


Before coding can complete the testing phase, it is important to put algorithms through a ‘dry run’ to
ensure that they all work as intended.
This is carried out by producing a trace table, which enables a programmer to work through the
code on paper, line-by-line, to check where variables, selection, sequencing and iteration take place.
The trace table also allows a programmer to check the results of the processing and to see what
should be output at any given point in the code.

Algorithm Design and Problem Solving 105

SB CS PP.indb 105 14.5.21. 14:15


Chapter 7
It is also important to try to list all of the possible user inputs into a program when designing a trace table.

Worked Example
A trace table
Consider the following simple program that iterates four times through an addition of  to a
starting number:

1 Number = 5
2 PRINT Number
3 FOR x FROM 1 TO 4
4 Number = Number + 3
5 PRINT Number
6 PRINT “Complete!”

The trace table for this program would look like this:

Line number Number x Output

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Complete!

Each time the variables change, their values are listed in the table. The trace then iterates back
through the loop as many times as has been programmed.

106 Algorithm Design and Problem Solving

SB CS PP.indb 106 14.5.21. 14:15


Chapter 7

Activity
Draw out a trace table for the following program:

1 Number = 18
LINK
2 PRINT Number
3 FOR y FROM 1 TO 5 See Chapter 8
Programming.
4 Number = Number + 7
5 PRINT Number
6 PRINT “Done”

Your table will require the following headings:

Line number Number y Output

. Error Checking and Correction


Two of the most common errors that can occur when writing programs are syntax errors and
logic errors.
• Syntax error: some of the code goes against the rules of the language that has been written for
the program. This can be a misspelling of a common word, omitting brackets or trying to call a
variable before it has been declared. DEFINITION
• Logic error: a program behaves unexpectedly and produces unusual results. This type of error can
occur when logical or Boolean operators are not used in the correct manner, putting a program Boolean: where a variable
accidentally into an infinite loop or using variable names wrongly. can have one of two
values, true or false.
The key difference is that with a syntax error the program will not run at all, whereas with a logic error
the program will run but it is likely to run incorrectly and not work as expected.

HELPFUL NOTES
Worked Example
Most programming
Syntax errors languages will have
Each of these lines of code contains a syntax error: syntax correction built in
and will even identify the
1 STRAT line where an error has
been found.
2 POINT(“hello world”)

3 INPUT(“What is your age: “

• Start has been spelt incorrectly in the first line.


• Point should be print in line .
• Line  has had a bracket opened but not closed – a close bracket should be added at the end
of the question.

Algorithm Design and Problem Solving 107

SB CS PP.indb 107 14.5.21. 14:15


Chapter 7
Logic errors
This program was written to determine whether a cheap travel fare can be applied for a young person.
LINK WB The program has been written in Python for the purposes of looking at the errors in detail.
Consolidate your
understanding by 1 Age = INPUT(“How old are you: “))
completing Exercise 5, 2 IF Age = 13:
page 78 in the Workbook.
3 PRINT(“child fare”)
4 ELSE
5 IF Age >=12:
6 PRINT(“child fare”)

This code will work when it runs, however there are several logic errors:
• In line , the program will respond if someone is exactly  and not  or under.
• In line , the program states that a child fare is payable if the passenger is greater than or
equal to  – this is incorrect and should be re-coded.

• The program also doesn’t enable an outcome for someone who isn’t a child passenger.

The program should look like this:


1 age = int(input(“How old are you: “))
QUICK CHECK 2 if age <= 13:
3 print(“child fare”)
What are the three types
of design documentation 4 else:
needed to create an 5 print(“adult fare”)
algorithm?

. Writing Algorithms


It is now your turn to create some algorithms. Work through the activities below. For each scenario,
create a flowchart and pseudocode, to solve the problem.

Activity
Design, document and code a solution to the following three problems:
A A cinema is looking for a system which only allows customers to see films that are appropriate to
their age. Using a date of birth, a system must determine whether a customer can buy tickets for
a Universal (U) film, a Parental Guidance (PG) film, a  rated film, a  rated film or an  rated film.
B A game needs to store the top ten scores for a level to be able to run a monthly competition.
Once a month ends, the top score from each month must be added to a table that shows all of
the top monthly scores in a year.
C A car hire company wishes to only hire Category  vehicles to customers who are over the age
LINK WB of , have a clean driving licence and have been driving for at least  years. They wish to hire
Category  vehicles to customers who are over , may not have a clean driving licence and have
Consolidate your
been driving for at least  years. They wish to hire Category  vehicles to customers who are over
understanding by
, may not have a clean licence and have been driving for at least  years. They do not wish to
completing the Exercises
1-3 from pages 66-73 in hire any vehicles to customers below the age of , regardless of their driving licence status or
the Workbook . how many years driving of experience they have.

108 Algorithm Design and Problem Solving

SB CS PP.indb 108 14.5.21. 14:15


Chapter 7

Algorithm Design and Problem Solving 109

SB CS PP.indb 109 14.5.21. 14:15


Chapter 7

Let’s Review

1 What are the four stages of the program development life cycle?
2 What is abstraction?
3 What is decomposition?
4 In a flowchart, what is this symbol used to represent?

5 Pseudocode uses only the syntax from a programming language to design a solution to a
problem. True or false?
6 What is the difference between a flowchart and a structure diagram?
7 Why is a linear search an inefficient way of searching through data?
8 What is an unordered data set?
9 Describe how a bubble sort works.
10 Name three types of data validation.
11 Visual checking is one form of data verification. Name the other type.
12 Explain the purpose of testing a program.
13 What is extreme data when testing a program?
14 What is the purpose of a trace table?
15 What type of error would be present if a common word had been spelt incorrectly?
16 Write an example of a logic error in a line of code.

110 Algorithm Design and Problem Solving

SB CS PP.indb 110 14.5.21. 14:15


CHAPTER

8
Programming

COMPUTER SCIENCE WATCH

Scan the page to watch a clip on Python


programming.
Before watching discuss what you expect
to see or hear.

QUESTIONS

• What are the key concepts of programming?


• What are the different types of data you
can work with when coding?
• How can you write code to do mathematics?
At the end of this chapter, you will be able to:
• What sort of programming goes into
understand how to use variables and constants a game?
understand how to use different data types
understand how to use sequence, selection and iteration
understand how to use totalling and counting methods
understand how to use string handling methods
understand how to use procedures and functions
understand how to use a range of library routines
understand how to create maintainable programmes
understand how to use both D and D arrays
understand how to use file handling methods

111

SB CS PP.indb 111 14.5.21. 14:15


Chapter 8
In Chapter  we looked at the importance of algorithms when solving computer problems. Computers
put these algorithms into action while using a programming language. When programming a piece
of software, algorithms and instructions can be communicated to a computer’s hardware to carry out
the requirements of a user.
It is important to note that there are many programming languages and, just like different spoken languages
from around the world, each one has its own set of unique words and rules. Even though some ideas
seem the same between different languages, the way of achieving the outcome can be quite different.

For the purposes of exemplification of coding, the programming language selected is Python.
There are a few examples where an alternative language has been used to give an example
and, where this is different from Python, this has been stated. The reasons for the differences is
that some of the examples in the IGCSE syllabus are not present within Python, so alternative
languages have been used to demonstrate these features. Python does not deal with arrays or
case statements and, in their place, the list and nested if functions are used instead.
QUICK CHECK

How much programming


have you done? What
languages have you
programmed? How . Programming Concepts
confident are you
with this?
.. Variables and Constants
Data can be constant or variable when used in a program. A variable piece of data can be changed
in some way, either by the user or the program. This data has to be declared by a programmer before
it can be used in code.
Declaring a constant or variable means that the type of data is defined, and an initial value for the
variable or constant is set. Variables do not have to have an initial value, but it is often useful. For
LINK WB
some programming languages, data types of constants and variables must be specifically declared
to be used in programming, however in others, such as Python and JavaScript, this is not the case.
Consolidate your
Constants stay the same every time a program is run or executed. They do not change their value. A good
understanding by
completing the Exercises
example of a declared constant might be an amount of time that something should take in a game.
1-2 from pages 91-92 in Variables are items of data that are expected to change during the program’s operation, usually
the Workbook. because of a question that has been asked or activities within the program. A good example of a
variable would be the high score for a game. Variables are a location within the computer’s memory,
and the data associated with the variable is stored in this location. The variable therefore needs to be
given a name by which it can be found during the program’s execution.

.. Basic data types


There are five basic data types that programmers use when creating code. These are used to declare
variables or constants.

Data type Definition Example

Integer This is either a positive or negative whole number. 


DEFINITION
Real This is a decimal number and can also be used .
Floating-point: a number to store integers. It is also known as the float
in programming that (referring to floating-point).
contains a decimal point, Char A data type used for holding a single character, £
and the decimal point
which could be a letter, number or symbol.
can ‘float’ in different
places to help with String A combination of letters, numbers and symbols PROGRAM
handling large numbers. held together as one piece of data.
Boolean A data type returning a True or False value, or  for FALSE
On and  for Off.

112 Programming

SB CS PP.indb 112 14.5.21. 14:15


Chapter 8
.. Input and Output
Input and output are another two important programming concepts, and refer to communication
between a program and a human user.

Input
The input is used where some information is required by the program, often from a user. The input is
used to prompt the user to enter some data. This type of input also requires an instruction to tell the WORD ALERT
user what sort of data they need to enter. Input can also come from within a program itself, although
this is often considered to be an inefficient way of coding. Another way of obtaining input is from an Inefficient: not the
external file that is linked to the program. best or fastest way of
achieving a goal.

Output
The output is where information is communicated back to the user as a result of the input. This is
usually done using the print function. This statement usually gives the user some information about WB LINK
the result they are about to see, and then the results of any calculations carried out on the variables
or constants are displayed. Consolidate your
understanding by
completing Exercise 3,
Worked Example page 94 in the Workbook.
Here is an example of some Python code for a program that calculates the area of a circle.
Mathematics and geometry show us we can calculate the area of a circle with this formula:

πr2

The symbol π (pi) is a constant and is equal to approximately . when rounded. To find the
area of a circle we first need to know its radius, r. Most programming languages have a pi
constant already built into their library of functions.
If we know that the radius of the circle is 5, we could write this Python code to calculate the area:

FROM math IMPORT pi


r = 5
PRINT (“The area of the circle with radius ” +
str(r) + “ is ” + str(pi * r**2))

The circle with a radius of  has been hard coded into this program and is stored as a constant.
However, it would be much more useful for the programming to be able to accept a user input
for the radius and store it as a variable, so that a circle of any radius could be calculated.
We could therefore consider the following adjustment to the Python code above:

FROM math IMPORT pi


r = float(input (“What is the radius of the circle : “))
PRINT (“The area of the circle with radius ” +
str(r) + “ is ” + str(pi * r**2))

This time the user is prompted to enter the radius, and the program uses that data to make the
calculation.

Programming 113

SB CS PP.indb 113 14.5.21. 14:15


Chapter 8

DEFINITION
.. Programming fundamentals
There are several constructs in programming and it is important to learn these so you can create
Constructs: the building your own coding. All algorithms that are written for programming require some constructs in order
blocks of programming. to work effectively.

... Sequencing
An algorithm contains instructions that are carried out one after another, and the sequence
determines the order that these instructions are carried out. For example, a basic algorithm for making
a cup of tea might look like this:
. Boil the kettle. . Pour water into the mug. . Stir.
. Put a teabag in a mug. . Add sugar and milk. . Drink the tea.
The numbers indicate the order of the steps, and these steps have been sequenced. Imagine if the
algorithm had been written like this:
. Put a teabag in a mug. . Boil the kettle. . Pour water into the mug.
. Stir. . Add sugar and milk. . Drink the tea.
The Stir step is now in an incorrect place, and the drink would not taste as expected, however a
REFLECT teabag could still be stirred at that point. This is a good example of a computer doing as it is told,
whereas humans would recognise that this sequence is wrong. It is therefore important that
Can you write an programmers get the sequence of their programming right to produce the desired result.
algorithm for an everyday
procedure?
... Selection
Another fundamental construct in programming is the ability for the code to make a decision or ask
a question, usually when there are several possible options.
Selection can be written into programs by using either an IF statement or a CASE statement.
Selection using IF statements allow a program to take different paths depending on the answer to a
question, and take the form of IF, THEN, ELSE instructions. For example, an algorithm could show a user
the most appropriate directions to a destination based on their mode of transport. The steps might be:

. Find out if you are in a car or on public transport.


. If driving a car, show a map using roads.
. Otherwise show a map with bus and train routes.
When preparing this algorithm for programming, we might consider the following:

. Are you driving a car or using public transport?


. IF you are driving a car, THEN look at this road map for directions.
. ELSE look at this map that contains bus and train routes.
Depending on the answer that is given at Step , the program can follow two different paths: one for
someone driving themselves, and another for someone using public transport.
Another form of selection is by using a CASE statement. This is where a set of options are
programmed for a question that has many different potential outcomes. For example, a program
may look up the answer to a question based on some similar variables, and output a word or phrase
based on the answer. Look at the following code from the Java programming language:
ENRICHMENT
CASE clothing of:
Write an algorithm in Shirt: OUTPUT “Monday”
standard English that
contains an if, then, BREAK;
else scenario. Jacket: OUTPUT “Tuesday”
BREAK;
Shoes: OUTPUT ‘Wednesday”
BREAK;

114 Programming

SB CS PP.indb 114 14.5.21. 14:15


Chapter 8
Jumper: OUTPUT “Thursday”
BREAK;
Shorts: OUTPUT “Friday”
BREAK;
DEFAULT: “I don’t know this clothing”

The selection will go directly to the appropriate line of code based on the input or condition that is
being tested, in this case an item of clothing that is associated with each day of the working week. If
the condition is not recognised, the program will go straight to the DEFAULT output. HELPFUL NOTES

... Iteration It is important to note


that the CASE structure is
Iteration takes place in an algorithm where the rules determine that a step or steps should be not built into the Python
repeated until a condition is met or until told to stop. Iteration is therefore the process of repeating programming language.
the steps in a program.
A straightforward algorithm for eating toast might be as follows:
Make the toast.
Put toast on the plate.
Put butter on the toast.
Cut toast in half.
Eat slice of toast.
Repeat step  until all of the toast is eaten.
Wash the plate.
HELPFUL NOTES
By inserting the line ‘Repeat step  until all of the toast is eaten’ the program is able to be simplified
by giving a repeat command until a condition is met, in this case when the toast is eaten. Iterating is the process of
Another word for iteration in programming is loop. In effect, the program is looping Step  until the repeating an instruction
set condition is met. as many times as the
program requires.
There are different types of loop in iterative programming.

Type of loop Description

Count-controlled loop The number of loops or iterations is already decided. A counter is used
to record how many times the iteration has occurred. This type of loop is
known as a FOR loop. (Example A)
Pre-condition loop This is where a condition must be true before the loop or operation takes
place. This type of loop is known as a WHILE loop. (Example B)
Post-condition loop This is where a condition must be true after a loop or operation has
taken place. In the C programming language, post-condition loops are
implemented using a DO-WHILE loop. (Example C) REFLECT
Another type of post-condition loop is a REPEAT ... UNTIL loop. This
repeats what is within the loop until the condition defined at the end is Can you write an
met. A pseudo-code example of this would be algorithm in standard
English for something
that requires repeat
count = 0 actions?
REPEAT
count = count + 1
OUTPUT count
UNTIL count == 10

This will output a count from  to .

Programming 115

SB CS PP.indb 115 14.5.21. 14:15


Chapter 8
Worked Example
Example A: Count-controlled loop (FOR)
If a program was written to add three lives to a total number of lives, the Python code could
read like this:

ADD Life
ADD Life
ADD Life

More efficient code would be::

REPEAT (ADD Life) 3 times

We would therefore write the actual code like this:


FOR count IN range(1,4):
PRINT(“Add Lives: “ + str (count))

This code would repeat the add lives command three times.
Example B: Pre-condition loop (WHILE)
This is a loop carried out while a question or a condition is true or false. If a program was
written to check that a door was open before switching on a light, the algorithm might look
like this:
Is the door open?
QUICK CHECK
Give the light electricity while the door is open
What are the three types
of iteration? Can you A piece of Python code might look like this:
confidently explain the
differences? Light = INPUT(“Type shut when you go out: “)
WHILE Light!= “shut”:
PRINT (Light)
Light = INPUT(“Type shut when you go out: ”)

This code would keep on asking the user to confirm the door was shut in order to end the
pre-condition loop and would carry on checking while the program was iterating.
Example C – Post-condition loop (DO-WHILE)
This is a loop that would be carried out after a condition is checked for either a true or false
answer to a question. Therefore, a do-while loop would always run once, even if the condition
checked is false, and would stop after the single iteration. If the condition was true, the loop
would iterate again.
It is important to note that the DO-WHILE iteration is not built into the Python programming
language. Consider this algorithm:
Are there  litres of water in the bucket?
Turn the tap off when there are  litres of water.
A piece of code from the Java programming language might look like this:

LINK COUNT = 1
WB
DO
Consolidate your PRINT(count)
understanding by count+=1
completing Exercise 5, WHILE count <5
page 96 in the Workbook.
This type of loop would repeat until the while line returned a false value. It would then stop
the program.

116 Programming

SB CS PP.indb 116 14.5.21. 14:15


Chapter 8
... Totalling and Counting
We now know that programs can use a counter when using a FOR loop. Counting keeps a check on
how many iterations a program has performed in a loop. For example, you might wish to count a
number of attempts at a level in a game. We might write a counter into Python code like this:

count = 0
count = count + 1 WORD ALERT

It is possible to insert the counter into an iterative loop to increment by  each time the loop is Increment: to increase
carried out. by a set number.

Totalling is used to add one number to an existing stored number, usually contained in two different
variables. For example, you might wish to add the number of different objects collected by a player
in a game. We might write a total in code like this:
total = total + items
Total and items are two different variables, and data would be stored in both.
REFLECT

... String Handling Have you ever played a


Strings are a data type used to hold combinations of letters and numbers, or alphanumeric game where a feature
included a counter?
characters. Strings are variables that can be assigned names and can be handled in several different
ways within programming.
A string might look like this in Python code:

Name = “Greg”
HELPFUL NOTES
The variable ‘name’ contains the combination of letters ‘Greg’. The contents could also include
numbers and symbols. Strings can contain letters,
numbers and symbols.
We are now going to look at the different ways strings can be handled.

Length
Coding can be used to discover the length of a string by using the syntax LEN. For example:
LEN(Name)
This Python code would return the answer ‘g’, as this letter is in the third position of the string ‘Greg’.

Character position
Another feature of string handling is determining the content of a character position in a string. For
example, we may wish the coding to look up the character at position  in the string:

Name[3]
WB LINK
This Python code would return the answer ‘g’, as this letter is in the third position of the string ‘Greg’.
Consolidate your
The reason ‘g’ is returned and not ‘e’ is because here the first character is in position []. However, in understanding by
some programming languages the first character of a string is denoted by position []. completing Exercise 7,
page 104 in the
Substring Workbook.
Another form of string handling is asking a program to look up a substring, or a set of characters
from within a string.

Name = “Greg”
OUTPUT substring(1, 2, name)

This Python code routine would return the characters ‘re’ from this code. The routine instructs the
program to create a substring from the variable ‘name’, starting at character position  (‘r’) and ending
at character position  (‘e’).

Programming 117

SB CS PP.indb 117 14.5.21. 14:15


Chapter 8
Upper and lower
This form of string handling turns all the lowercase letters in a string into uppercase (upper) or all the
QUICK CHECK
uppercase letters in a string into lowercase (lower), and then returns it. For example:
Why does position [3] in
the example output the
Name = “Greg”
letter ‘g’? Print(Name.UPPER())

This Python code would return the output of GREG, as the ‘reg’ part of the string has been converted
to uppercase.

Name = “Greg”
PRINT(name.LOWER())

ENRICHMENT This Python code would return the output of greg, as the ‘G’ part of the string has been converted
to lowercase.
Can you think why it
would be useful to output
a portion of a string? ... Arithmetic, Logical and Boolean Operators
An important feature of programming is the ability to carry out mathematical operations. The tables
below show the different types of operations that can be carried out within programming languages
and some example syntax.
REFLECT
Arithmetic Operators
Many popular games
use this coding feature These operators are used to carry out arithmetic calculations.
to personalise a game.
A user is asked to enter Operator Purpose Syntax
their name, and it then
appears throughout the + Carrying out an addition Lives = Lives + 1
gameplay.
− Carrying out a subtraction Lives = Lives - 1

* Carrying out a multiplication Lives = Lives * 2


HELPFUL NOTES / Carrying out a real division Lives = Lives / 2
Many of these operations ^ Raised to the power of Lives = Lives^2
are identical to
mathematics. MOD Finding a remainder from the Lives = Lives MOD 3
division of two numbers
DIV Carrying out an integer division Lives = Lives DIV 3

The difference between a real division and an integer division is that an integer division can only be
carried out where the two pieces of data being divided are both integers. Where one of the pieces
of data is not an integer, and instead may be a floating-point piece of data, a real division should be
programmed instead.

Logical Operators
These operators are used to carry out comparisons and are often found in iterations.

118 Programming

SB CS PP.indb 118 14.5.21. 14:15


Chapter 8
Operator Purpose Syntax

= Assigning a value to a variable (assignment) Lives = 10

< Less than IF Lives < 10

<= Less than or equal to IF Lives <= 10

> Greater than IF Lives > 10

>= Greater than or equal to IF Lives >= 10

<> Does not equal IF Lives <> 10

Boolean Operators
These operators are used to help a program make more complex decisions.

Operator Purpose Syntax


LINK
AND If something and something else are true IF Lives > 5 AND
Health >=10 Chapter 10.
or false
OR If something or something else is true IF Lives > 5 OR
or false Health > 10

NOT If something is NOT true or false WHILE NOT Lives

.. Nested Statements


We have already learned about the programming constructs of selection and iteration. Sometimes
it is necessary to execute one IF statement, followed by another, followed by another. This would
form a subroutine, whereby the results of the first selection would execute the inner selection, which
in turn would execute the innermost selection. The same would happen with an iterative process,
whereby the results of the first loop would execute the inner loop, which in turn would execute the
innermost loop.
We refer to this type of iteration as nesting, and both selection and iteration is capable of these
constructs.

Nested Selection
This type of programming usually involves several decision points within a process. For example, if
Film A was rated at , and Film B was rated at , some Python code could be written for making a
decision on whether someone could view one of the films.

Age = int(input(“What is your age? “)


IF Age >= 12 THEN
OUTPUT(“You are able to watch Film A”)
ELSE
IF Age >= 15 THEN
OUTPUT(“You are able to watch Film B”)
ELSE
OUTPUT(“You cannot watch any of the films”)
ENDIF
ENDIF

Programming 119

SB CS PP.indb 119 14.5.21. 14:15


Chapter 8
Nested Iteration
In the same way as a selection can be nested, a loop can be nested inside another loop. In this example,
the inner (nested) loop would output ‘ to ’ four times because of the iterations specified in the outer loop.

FOR Lives = 1 to 4
FOR Health = 1 to 5
PRINT(Health)
NEXT Health
NEXT Lives

You would need to be able to create nests of up to three levels of statements in your programming,
either as nested selection or nested iteration.

.. Procedures, Functions and Parameters


ENRICHMENT Within a computer program there are different sections of coding that do different jobs. Some of
these sections are procedures, and others are functions. These can be run at set times within the
Can you think of programming. Often, procedures and functions are run several times within a program, and so they
a procedure or a tend to be pre-stored within a programming language ready to be called when required. This saves
function that could be time as the programmer does not have to type out common functions and procedures repeatedly.
used regularly? Hint:
Programming languages come with functions and procedures that are pre-defined. However,
think of formulaes in
mathematics.
programmers will often write their own functions and procedures that are relevant to the program.
A function can be called by a procedure, but a procedure cannot be called by a function.

Worked Example
A procedure
If a program needs to create several equilateral triangles of the same size, the algorithm to
create one triangle might look something like this:
Repeat  times
Draw a line length 

QUICK CHECK Turn right  degrees


This procedure could then be named triangle and at any point the programmer could run or
What is the difference ‘call’ the triangle procedure to run this code.
between a procedure and
a function? A function
If a program was required to find the perimeter of a triangle, the Python code might look like this:
Perimeter_Triangle = (Line * 3)
RETURN Perimeter_Triangle

This function would be able to be used at any point to return a perimeter of a triangle where
the line length variable had been previously defined. This calculation would be stored as
Perimeter_Calculate, and this could then be returned and used in the program
whenever needed.
WORD ALERT

Function: a block of To carry out processes, a function or procedure sometimes requires additional information or
organised, reusable code instructions from the programmer. These instructions are called parameters and are the names of
used to perform a single, information required.
related action.

120 Programming

SB CS PP.indb 120 14.5.21. 14:15


Chapter 8
Our triangle procedure in the worked example had a preset line. This could easily be swapped for
a variable instead, which for example could be called Linelength. This parameter could then be
inserted into the procedure, and a line length could be added to the calling of the procedure instead
of the length being hard coded into the procedure. This makes for more efficient coding:
Triangle(100)
This line, with a parameter built into the triangle procedure, would then draw a triangle with sides
of length . The number is called the argument; procedures and functions can have multiple
arguments, separated by commas, as long as there are parameters built into the code that are
waiting to accept those arguments. REFLECT
There are also differences in the variables that can be used by functions and procedures:
What parameters might
• A global variable is declared outside of functions and procedures and can be used within any
you be able to attach to
function or procedure in the program. a procedure that draws
• A local variable is declared inside a function or procedure and can only be used by the function a circle?
or procedure that it is contained within.

.. Library Routines WB LINK


Library routines are small blocks of pre-written code that are stored within the library (a type of
database) of a programming language. These are perfectly programmed routines that can be called Consolidate your
understanding by
upon at any time with no pre-programming required and are designed to handle some of the most
completing Exercise 4,
common problems when writing any software.
page 95 in the Workbook.
Here are some common library routines:
• MOD: Short for modulo, this routine is used for finding a remainder from a division.
• DIV: Short for division, this routine is used for carrying out a division of two integers. ENRICHMENT
• ROUND: This function returns the output of the nearest integer to a floating-point number that is
passed to it. Look for some other
common library routines
• RANDOM: This function returns a randomly selected integer from a given range of integers. in the programming
language that you use.
.. A Maintainable Program
It is important for programmers to create tidy, well-explained and efficient code. It is highly likely that
at various points in the coding process the code that has been written will be passed on to another HELPFUL NOTES
programmer to work on, complete or test. If the coding is messy, inefficient or lacks sufficient
explanation, this can make the process of handing over very difficult or even impossible. Line numbers in
programming are vital.
Meaningful Identifiers You can use them to
quickly identify errors
It is very important that the variable names used within code are related to the data contained inside in coding.
that variable. For example, the variable name ‘item’ does not describe what that variable contains
or is used for. The same goes for constants, arrays and procedures – all identifiers should be easily
recognisable by programmers to ensure the code can be easily read.
REFLECT
Commenting
Adding commentary to lines of code is a feature in all programming environments. These are lines Think about your own
of description that are added next to actual code. Comments are not executed by the program and programming. Would your
are separated from the coding using a special symbol. These symbols are different depending on the comments be able to be
language being used. Commentary can show what a programmer or developer was thinking at the understood by someone
time of writing a particular line or set of lines of code, and any programmer working in a team would who had no knowledge of
be able to access other people’s coding much more easily. your program?

Programming 121

SB CS PP.indb 121 14.5.21. 14:15


Chapter 8
Procedures and Functions
Many common procedures and functions that are stored in the library (see .. Library Routines)
have set names that are common across most high-level programming languages. When a
programmer is writing their own procedures and functions, it is important that the names they give
are not likely to cross over with anything else, as this would cause an error in the programming.
For example, if writing a procedure to draw a circle, the procedure could not be called Round
because this is already in use within the library. A better name would be Circle as this would not
ordinarily be used by another function or procedure.
LINK WB

Consolidate your
understanding by . Arrays
completing Exercise 8,
page 106 in the In .. we learned that variables are memory locations that can store a piece of data. An array is a
Workbook.
series of these memory locations, where all of the data that is stored are related in some way – the
same data type. Each location can still only store one piece of data, but locations can be grouped
together. In Python, arrays are created using the LIST functionality.

Worked Example
A program may be required to store five colours. The code could be written like this:

Colour_0
Colour_1
Colour_2
Colour_3
Colour_4

While this would work for storing the five colours, an easier way to store the data is in an array:

Colour(4)
REFLECT
Imagine a table like this, called colours:
What is the difference
between a one- and
Colours
two-dimensional array?
    
Red Green Blue Purple Orange

The number in brackets defines the index and determines how many pieces of data can be
stored in the array – in this example, the number  would allow five items to be stored. As we
learned in Section ..., computers begin counting at the number , however some languages
do begin counting at number .

122 Programming

SB CS PP.indb 122 14.5.21. 14:15


Chapter 8
Arrays can be both one- and two-dimensional. The colours example above is a one-dimensional
array: one row and multiple columns. A two-dimensional array has multiple columns and multiple
ENRICHMENT
rows of data, all with the same data type – this looks a bit like a grid. One example of a two-
dimensional array is where a program needs to map out a game world of a fixed size, with each Think of a game where
square of the game world containing data to define the type of land in a square. the world appears to be
three-dimensional. Try to
World [20][20] imagine the size of array
that exists to code just
The code above would allow a programmer to define a flat world in a game that is  squares wide the world without any
by  squares in length using a two-dimensional array. More complicated game environments use characters in it.
three-dimensional arrays.
Data can be read from and written into arrays depending on the functionality of the programming.
If the program was required to read the third value from the colours array in our example above, the
following code could be used:

Colours[2]

This would give an output of Blue, the third colour in the array.
It is also possible to change or write to an array, for example in the code below, which would change
the data in array position  from green to pink.

Colours[1]=”Pink”
REFLECT
It is also possible to create, write to and read from arrays using iteration. Creating an array using this
method could be done using a nested FOR loop:
Can you think of a
scenario in a game where
World= [[0 FOR x IN range (5)] FOR y IN range (5)] data in an array might
need to be changed by
This code would create a two-dimensional  ×  array. a program?
The array could then have data written into each position, which is similar to grid references on
a map:

World[0][0] = ‘Red’
World[0][1] = ‘Blue’
World[0][2] = ‘Orange’
World[0][3] = ‘Orange’
World[1][0] = ‘Green’

[0] [1] [2] [3] [4]

[0] Red Blue Orange Orange


WB LINK
[1] Green
Consolidate your
[2] understanding by
completing Exercises 1
[3]
and 2, pages 107-110 in
[4] the Workbook.

Programming 123

SB CS PP.indb 123 14.5.21. 14:15


Chapter 8

HELPFUL NOTES
. File Handling
Files that are handled by
programming languages We have seen that programming involves the input of a lot of data, whether as variables and
tend to be text files, such constants or output of results of operations. It is therefore often important to store program data
as those viewable in a in external files so that it is not lost when a program has finished running. Programming can often
program like Notepad. take weeks and months to create, and to be constantly restoring data to code would be hugely
time-consuming.
To enable greater efficiency, programming languages have the ability to handle external files of data.
The files can be both read from and written to. When reading from a file, a program can be instructed
to open it, read from it and close it again. When writing to a file, a program can be instructed to open
it, write data to it, save it and close it.

.. Reading from a File


When reading from a file, a program will read records one line at a time. Data held in a file can be
read into a variable or into an array.
Here is an example of Python code for reading a single line from a file called colours.txt that
has only got one line of information:
FILE = openRead(“colours.txt”)
Colour = myFile.readLine()
FILE.CLOSE()

This Python code would open the colours.txt file, read the contents of the file into a variable,
create a single record from this data and then close the file. If a file has multiple lines of data, this
would have to be read into an array and would create multiple records.

.. Writing to a File


A program can also be set up to write the contents of a variable or an array to a file – the reverse
of the reading operation. Data is written into a file one line at a time. An example of this is shown in
the Python code below, where the contents of the colours array can be stored in a file called
colours.txt.
LINK WB
FILE = openWrite(“colours.txt”)
Consolidate your FOR x = 0 TO 5
understanding by
completing Exercise 1, file.writeLine(colours[x])
page 111 in the next x
Workbook.
FILE.CLOSE()

This Python code would write the data stored in the colours array to the colours.txt file line
by line.

124 Programming

SB CS PP.indb 124 14.5.21. 14:15


Chapter 8

Let’s Map It

Sequence
Logical order

Selection
Constants
If something is true THEN
Don’t change
do this ELSE do that

Iteration
Variables
Looping until
Can be changed
something happens

INPUT PROGRAMMING OUTPUT

Data types Procedures and


Functions

Pre-named and
Pre-defined
Integer 0, 1, 2, 3
LIBRARY
Real 1.3, 2.6, 3.7
Char £, $, ¥
String hello
Boolean True/False

Files
Arithmetic Arrays
+ - * / = >< Tables of data

Boolean
AND OR NOT
Read from Write to

Programming 125

SB CS PP.indb 125 14.5.21. 14:15


Chapter 8

Let’s Review

1 What is a variable?
2 Name two data types used in programming.
3 Explain what the programming construct of sequence means.
4 CASE statements are one form of selection – name another.
5 Name the three types of iteration loops.
6 What is the purpose of counting in programming?
7 When handling strings, name two ways in which they can be changed.
8 Addition and multiplication are two arithmetic operators. Give another three.
9 What is the meaning of the logical operator <>?
10 Boolean operators are used for complex decisions. Explain the three common operators, AND,
OR, NOT.
11 What does it mean to use a nested statement?
12 What is a parameter?
13 What is the difference between a local and a global variable?
14 Name two library routines in a programming language.
15 Why is it important to use meaningful names to identify variables and constants?
16 What is the commenting feature of a programming environment?
17 What type of item is stored in an array?
18 True or false: data can only be read from an array.
19 Why do programming languages use external files for data storage?
20 True or false: a program reads all of the lines from a file in one go.

126 Programming

SB CS PP.indb 126 14.5.21. 14:15


CHAPTER

9 Databases

COMPUTER SCIENCE WATCH

Scan the page to watch a clip on database


management systems.
Before watching discuss what you expect to
see or hear.

QUESTIONS

• How are records maintained in


organisations like your school or any
other place?
At the end of this chapter, you will be able to: • Ask your elders and understand the
different methods of record keeping in
understand what is meant by a database, including features such as tables,
earlier times.
fields and records
be able to suggest suitable basic data types for fields
identify the purpose of a primary key in a database
understand structured query language (SQL) and how to use it to
create queries

127

SB CS PP.indb 127 14.5.21. 14:15


Chapter 9

QUICK CHECK
. Understanding Databases
What is the difference Let us first understand what data is. Data can be
between data and anything that can be stored on a computer, like
information?
numbers, letters, characters, images and so on.
Have you seen the computer-generated bills from a
supermarket, or a shop (Figure .)? What information
do you get from the bill? Had there been no mention
about the item ID or name, would it be easy to
understand the purchases made? When the data
is presented in a meaningful way, what you get is
information.
A database is an organised collection of data. In a Figure . A sample shopping bill.
database, you can organise data in a table format.
It also allows the user to work on data in the
following ways (Figure .).

Ad or remove
HELPFUL NOTES data
Avoid data
Microsoft Access is one
Database duplication
of the most popular tools
for working on databases. Manipulate or
change data
Since it comes along
with the Microsoft Office
Maintain data
accuracy and
Suite, the interface is very consistency
similar to other Microsoft Access or
applications. analyse data

Share data
Store data

Figure . Uses of a database.

REFLECT Databases are used in different places to store and manage information about almost everything.
Some common applications of databases are:
Can you think of more
places where a large Student and examination records at schools and universities
amount of data is stored
using a database? Book records at libraries or book stores
Patient records at hospitals (Figure .)
Customer records at banks
ENRICHMENT Booking and reservation records at railways and airports
Employee records at offices
Find out how a country’s
population data is stored. Online registration records for websites and social media
Figure . Accessing medical records.

128 Databases

SB CS PP.indb 128 14.5.21. 14:15


Chapter 9
.. Important Terms related to Databases
Table: In a database, data is entered in a tabular format, that is, organised as rows and columns to
provide meaningful information. This structured entry of data helps the user to access and manage
the information easily.
A column in a database table is referred to as a field. A field is like a title given to every single piece WORD ALERT
of data. Each row is called a record, which is a collection of fields in the table for a specific person,
item or any other entity. Entity: object or thing.
Let us look at an example of a database table showing records of students appearing for their final
examination. Here the field names are given by Student ID, First Name, Second Name, Date of Birth,
Contact number.
A column or a field QUICK CHECK

What is a field?
A row or
a record

Figure . Student record table.


Query: Sometimes you need to work with a very large database. In such cases, it may be difficult WORD ALERT
to find specific data required by the user. A query allows the user to find full records or records with
specific fields in a database using certain criteria. For example, in the student record database Criteria: conditions or
(Figure .), you can run a query to find the information of students from roll numbers  to . You will questions.
learn more about how to use a query for practical purposes later in this chapter.
Data types: A field in a database table can have its own attribute or property. For example, you
can enter data as text, number, date/time, currency and so on. These attributes are defined as data
types. A data type helps the computer to identify similar data for the purpose of sorting, searching
and calculation. Mostly data types may be defined differently in various database systems. Some
common data types are as given in Table ..
Table . Some common data types.

Data type Attribute description Example of field name Sample data

Text/Alphanumeric Used for data which Student name, phone David,


is text or number or a number, address Manisha
combination of both. WORD ALERT
Character/Char Used for defining data Name, address, title Mr,
with a fixed-length string String: a set of characters
Mrs,
that may contain letters, that can also contain
numbers and/or special Miss spaces and numbers.
characters.
Integer Used for data which is a Roll number, ID, number ,
whole number. of items 
Number/Numeric Used for numbers greater Height, weight, score .,
than zero and may require .,
calculations. It can also
have a value in decimals .%
or percentages.
Real Used for data in a Weight, height, ., .
computer program which temperature
are decimal numbers.

Databases 129

SB CS PP.indb 129 14.5.21. 14:15


Chapter 9

Data type Attribute description Example of field name Sample data

Date/Time Used for date or time. Schedule, last date, first //,
Different formats of date, time of action ::
date such as DD/MM/
YY and time such as
hours:minutes:seconds
can be selected.
Currency Used for data that include Item price, cost, tax paid, £.,
currencies of different amount credited $.
regions around the world.

AutoNumber Used for data which Registration number, 


can include randomly product ID, student roll 
generated numbers when number
a record is added. This
field cannot be changed.
Boolean Used for data which has a Answer (true/false), active Yes,
value of / such as True/ (yes/no), display (on/off ) no,
False, Yes/No, On/Off.
true,
false

DEFINITION . Types of Databases


Primary key: A primary
key is a unique field that You can use different software applications like Microsoft Access, Oracle, MySQL, LibreOffice Base
allows the user to identify to create a database. These applications are also called Database Management System (DBMS)
a record.
applications as they act as an interface between the user and the database. A database can be of
Foreign key: A foreign key two types — Flat-file (single-table) database and Relational Database (Table .). Different
is a field or combination
DBMS applications work on any one type or both types of database according to how they are
of fields that are related
programmed. For example, Microsoft Access can work on both flat-file and relational databases.
to the primary key of
another table. Thus, Access is also a Relational Database Management System (RDBMS).

Table . Types of databases.


HELPFUL NOTES . Flat-File Database (single-
. Relational database
table database)
A primary key cannot
have a duplicate value A flat-file database stores When a database can have mutiple related tables, it is referred to as
in a database. Also, this simple data formats. They store a relational database. When the tables are linked, the user can work
field cannot be left blank. only a single table of data. The on complex data structures having multiple tables (Figure .b).
information given by a record is For example, in a student database, you can create a Student
complete with a fixed number Information table and a Student Examination table.
WORD ALERT of fields. This database is not
related to any other table or In the Student Information table, Student ID will be unique for
Data duplication: a database. An example is shown each student record. It thus defines the record of each student. This
process of creating an in Figure .a. special field is defined as the Primary key for that table. Now, when
exact copy of data. you link the Student Information table and Student Examination
This method of storing data is table, the two tables can have a common field, that is Student IDs.
Data redundacy: the not efficient and may lead to
storing of the same data problems like data duplication, A relational database does not allow data duplication. Also, it is
in multiple locations. more effiecient and consistent than a flat-file database.
data redundacy and input errors.

130 Databases

SB CS PP.indb 130 14.5.21. 14:15


Chapter 9

WB LINK

Consolidate your
(a) Flat-file or single-table database (b) Relational database understanding by
Figure . Example of databases. completing Exercise 1,
page 115 in the
Workbook.
Activity
1 An organisation keeps a record of its employees in separate tables like Employee Joining Details,
Employee Payroll Record, etc. Suggest a common link which can help to retrieve all the records
of a particular employee. Which type of database must be created?
2 Fill in the blanks.
a) A database is an organised collection of __________.
b) A flat-file database is also referred to as __________.
c) A ________ key is a unique field that allows the user to identify a record.
d) The full form of DBMS is __________________________________.

. Creating a Database


.. Creating a New Database with the Given
Information
Let us look at the given information.
In an inter-school annual sports meet, registration forms were collected with the following
information. You are asked to enter the information from the forms into the student database.
Given below is the information collected from different schools.
• Registration Number
• School Name
• Student ID
• Student Name
• Age HELPFUL NOTES
• Gender
If the application is open
• Contact
then you can create a new
• Sport Selected file using the File tab in the
You can create a table using any database application. Here, you will be looking at Access . open document.

To create a database in Access, follow these steps. To create a new database


file, you can either select
Step 1: Open the Access  application.  Step 2. In the Backstage view click on the Blank the Blank database option
database option (Figure .).  Step 3. A dialogue box opens (Figure .)  Type the name of the or a built-in template.
database as Annual Sports Meet.  Step 4. Click Create.  Access  window will open.

Databases 131

SB CS PP.indb 131 14.5.21. 14:15


Chapter 9

Figure . Backstage view of Access 2016.

Figure . Creating a new database file.

.. Creating a Table


Access has two views to work with data: Design View and Datasheet View. These two views can
be toggled with the help of the View option under Home tab (Figure .).

Figure . View option.


Although both the views allow the user to create and define the table structure, the Design View is
easier to work with.

132 Databases

SB CS PP.indb 132 14.5.21. 14:15


Chapter 9
When you switch to the Design View, you will be prompted to save the table. Enter the table name
as Student Participation Table and click OK (Figure .).

Figure . Saving a table.

The Access window will show the Design View. Now, you can add the Field names for a record,
define its data-type and mention the Field Properties. You can also set the Validation Rules from
the Properties pane (Figure .).

Figure . Entering table fields and defining data types in Design View.

By default, the first field is marked as a primary key (shown by a key icon). You can change the
primary key by right-clicking on the desired Field name and selecting the Primary key option or
just select the Field and click on the Primary key option under the Design tab.

.. Data Validation


DEFINITION
You have learned that data can be a name, date of birth, address, currency, date/time, and so on.
There are certain rules that are followed when data is typed into a database system called the data Data validation rules: these
validation rules. For example, a phone number does not contain a character or an alphabet. These are some rules which help
rules help in accepting the data which are as per the set format. the user to know that the
data being entered in a
The data entered into a database can sometimes be entered incorrectly. It can be invalid, database is correct.
inconsistent or incomplete. To avoid any such issue, the user may apply different validation checks.
Some of these are given in Table ..

Databases 133

SB CS PP.indb 133 14.5.21. 14:15


Chapter 9
Table . Types of data validation checks.

Validation
Purpose Example
technique

Presence check To check the missing data in the A primary key in a database is
field. The system does not move mandatory.
further if this data is not filled.
Range check To check if data is within the set Days of a week must be between 
range. and .
Length check To check the desired length of data If the format of time is hrs:min:sec,
characters is met or not. the system will require  digits to be
entered, anything less than  digits
will not be considered valid.
Format check To check if data is in the desired The date format followed in a form
format. can be mm/dd/yyyy.
Consistency check To check that data is consistent as The date of expiry of an item cannot
per any previous entry. be before the manufacturing date.
Type check To check the data type. A phone number field cannot allow
characters.

You can add a validation rule to a field using the Field Properties Pane (Figure .). Once the data is
entered, a validation check can also be performed. To do so, select the Design View  Design tab 
Click on Test Validation Rules.

Figure . Creating validation rule for Student Participation Table.

.. Entering Data in a Table


When a form is designed, save the table and switch to the Datasheet view to enter the data values
(Figure .).

Figure . Annual sports meet database.

134 Databases

SB CS PP.indb 134 14.5.21. 14:15


Chapter 9

. Using Queries HELPFUL NOTES

You can create queries


Queries are used for working with data in a database. You can search data by certain criteria such as by choosing one or more
“searching the records in which the students have participated before”. You will get the matching search criteria.
records in the database.
Structured Query Language (SQL) is mainly used for creating and running a query in order to
search, sort or manipulate data.
However, some DBMS systems like Access also allow the user to create a query using a Graphical
User Interface (GUI). This is sometimes referred to as query-by-example.

.. Using Query-by-Example WB LINK


Using the Student Participation Table created earlier, let us create and run a query to search the
Consolidate your
records of all students playing the sport ‘Baseball’. understanding by
To do so, follow the steps given. completing Exercise 2,
page 116 in the
Step 1. Open the database - Annual Sports Meet.  Step 2. Click on Create tab  Query
Workbook.
Design option.  Step 3. A new tab opens in the Access window called Query 1. 
Step 4. Select the table name from the pop-up window and click on Add. Click Close to close the
pop-up window.  Step 5. A list of all fields in the table appears in the top pane of the Query 1
window. You can create a query and set a criterion or multiple criteria to search the database by
filling up the options in the lower pane of the Query 1 window (Figure .).  Step 6. Run the
query by clicking on the Run option in the Design tab. The required data will appear (Figure .).

Figure . Creating a query.

Databases 135

SB CS PP.indb 135 14.5.21. 14:15


Chapter 9

Figure . Results of a query.

.. Using SQL Programming


SQL is mainly used for relational databases. It contains statements which are used to retrieve or
modify data from the database.
Access also allows you to use SQL to create queries. Let us again take the example of the Annual
sports meet database.
To create a query using SQL, follow the given steps.
Step 1. Open the Query 1 tab  Once this tab is opened you will notice one more view in the
View tab called SQL view (Figure .). Select the SQL view. The Query 1 window will change to
the programming environment for SQL.  Step 2. Type the SQL queries and Select Run from the
Design tab.

Creating the SQL query to retrieve data from the


database
The syntax used for Data Query Language is:
SELECT [Field Name] FROM [Table Name];
Now, let us understand the application using Student
Participation Table.
. Using * for the field name
This will retrieve all properties (fields) of a table
Example
SELECT *
FROM [Student Participation Table]; Figure . View tab with SQL View option.

HELPFUL NOTES

Some more operators you


can use with WHERE clause Figure . Output for SQL query using.
< Less than
> Greater than Output: You will get the complete table information
including all Field names.
= Equal to
!= Not equal to . Using WHERE clause
<= Less than and WHERE clause is added to specify a condition. When
equal to this clause is added to a SQL query you will get only
>= Greater than and those records for which the condition is true.
Figure . Output for SQL query using
equal to Example WHERE clause.
BETWEEN Within a defined SELECT [Registration Number], [Student ID], [Student First Name]
range of data FROM [Student Participation Table]
WHERE Age<=;

136 Databases

SB CS PP.indb 136 14.5.21. 14:15


Chapter 9
. Using ORDER BY clause
ORDER BY clause is used along with the
SELECT statement to retrieve information
in ascending order. In case you require
information to be arranged in descending
order, DESC is used along with the ORDER BY
clause.
Syntax
For Ascending order (Output Figure .)
SELECT [Registration Number], [Student ID],
[Age] Figure . Output for ORDER BY ascending order.
FROM [Student Participation Table]
ORDER BY Age;
For descending order (Output Figure .)
SELECT [Registration Number], [Student ID],
[Age]
FROM [Student Participation Table]
ORDER BY Age DESC;
You will also learn about two more functions,
COUNT and SUM. These are aggregate functions
which are used for performing mathematical
operations – counting and addition,
respectively on the data values of a given field.
COUNT function – It is used for counting the Figure . Output for ORDER BY in descending order.
number of rows in a field. You can add a
condition using WHERE clause.
Example
SELECT COUNT (Age)
FROM [Student Participation Table]
WHERE Age = ; Output is shown in Figure ..
Figure . Output using COUNT
SUM function – It is used for adding the values in function.
a given field.
You can use the SUM function to add the values
in the field, Reg_Amount (Figure .) using the
SQL query.

Figure . Reg_Amount field of Student Participation Table.

SELECT SUM (Reg_Amount)


FROM [Student Participation Table]; Output is
shown in Figure ..
Figure . Output using SUM function.

Databases 137

SB CS PP.indb 137 14.5.21. 14:15


Chapter 9

Activity
Answer the following.
 Name any DBMS application that allows creating a query using Query-by-example and
SQL, or both.
 The full form of SQL is _________.
 Which SQL function allows you to arrange data in ascending order?
 Write the syntax for a WHERE clause.

138 Databases

SB CS PP.indb 138 14.5.21. 14:15


Chapter 9

Let’s Map It

Applications of a database
• Storing/sharing data
• Accessing data
• Manipulating data
• Adding/Removing data
• Avoiding data duplications
• Maintaining data accuracy/
consistency

Understanding databases
• Important terms related to databases
• Table • Field
• Query • Record
• Data types • Primary key

Datatypes
• Text/Alphanumeric
• Character/Char
• Integer
• Numeric
• Real
• Date/Time
• Currency
Types of databases • Autonumber
• Flat-file database
• Boolean
• Relational database

DATABASES
Creating a database
• Creating a new database
with the given information
• Creating a table
• Data validation
• Entering data in a table

SQL commands:
• SELECT
• FROM
Using queries
• WHERE
• Using Query-by-example
• ORDER BY
• Using SQL programming
• SUM
• COUNT

Databases 139

SB CS PP.indb 139 14.5.21. 14:15


Chapter 9

Let’s Review

 Define a database.
 Explain the difference between flat-file and relational database.
 Name some statements that can be used to retrieve data using SQL queries.
 Define data types. State three data types.
 Assuming you need to plan a health camp for your school, create a sample student database
assuming students between age group – will participate.
 Explain validation. Why is it required? Give the names of any two types of validation checks.
 In a hospital a patient database is to be created with the given fields

Patient First Second Contact Blood Date of Age Doctor Date of Fee
ID Name Name Details Group Birth Consulted Visit Paid
Assuming you have to maintain the patient database, create a database with at least ten records
and define the following.
a) Primary key
b) Data type for each field
 In the above table create SQL queries for:
a) Selecting the patients who consulted a specific doctor
b) Getting a total sum of fee paid
c) Arranging the records in ascending order of Age

140 Databases

SB CS PP.indb 140 14.5.21. 14:15


CHAPTER
Logic Gates
10 and Circuits

QUESTIONS

• How could logic gates be used in everyday


life?
• How are logic gates and micro controllers
used in all computer systems such as
games consoles?
At the end of this chapter, you will be able to: • What are digital circuits in computer
understand the different symbols that are used for logic gates systems and how do they use binary values
1s and 0s?
understand the function of a range of different logic gates
use logic gates to create a logic circuit
complete a truth table
write a logic expression

141

SB CS PP.indb 141 14.5.21. 14:15


Chapter 10

DEFINITION
. Logic Gates
Logic gates: the basic Logic gates are the basic building units of any digital circuit. Today, these circuits are used in almost
units of a digit circuit every computer system. From elevators to washing machines, logic gates are used all around you.
that control the flow of
electronic signals.

Digital circuit used to open electronic door.

WORD ALERT
This chapter will explore the types and functions of common logic gates.
Combination: a joining There are a number of different types of logic gate, with different logic rules. The combination
of different parts or of several logic gates forms a circuit, which allows for the design and performance in modern
qualities. computers. The gates receive binary data, apply a Boolean operation and then output a binary result.
Arithmetic: use of
numbers to calculate an
outcome. Boolean Operations
Equivalent: the same or The word ‘Boolean’ comes from Boolean algebra, which is the basis of computer arithmetic and
equal meaning.
especially logic gates. There are only two Boolean values: true and false. They have equivalents in
normal language and in binary notation.
Boolean expressions can compare data of any type as long as both parts of the expression have the
HELPFUL NOTES
same data. In computer science, Boolean expressions can be used in programming and produce
Be careful not to confuse
Boolean values when evaluated. Boolean values are either true or false:
the Boolean operator ‘+’
with ‘+’ , which means Boolean value Binary value Synonyms
‘plus’ in normal maths.
True  On Yes Positive
False  Off No Negative

There are also three logical operators: NOT, AND and OR. The Boolean operators for these are AND ‘•’,
OR ‘+’, and NOT ‘ ’, which is written above the letter.
Ā means NOT A.
A • B means A AND B.
A + B means A OR B.
Logic gates use both Boolean values and operators.

142 Logic Gates and Circuits

SB CS PP.indb 142 14.5.21. 14:15


Chapter 10
Worked Example
We use Boolean logic all the time. Look at this situation using Boolean operators:
You have decided that you will do extra study if you are falling behind at school. You also decide
that you will do extra study even when you are not behind if your friend asks you to study
together. Express this using Boolean operators.
WORD ALERT
Solution
To express this formally and logically we need two pieces of information to make our decision Formally: officially /
and another piece to represent the result of the decision. We can name our information like this: explicitly.

Information needed to make decision


(behind at school) = TRUE if fall behind. If not, FALSE.
(friend asks you to study) = TRUE if friend asks you to study. If not, FALSE.
Result
(do extra study) = TRUE if we decide to do extra study. If not, FALSE.
Our logical expression is then:
(do extra study) = (behind at school) OR (NOT (behind at school)) AND (friend asks you to study)
This expression uses the three Boolean operators: NOT, AND, OR.

Activity
1 Write a logical expression like the example above for this given scenario.
There are two methods of getting to your part time job on time. You can get the bus but only if
you wake up before .am. If you wake up after this time, you will need to ask your parents to
take you in the car. If you wake up before .am but your parents offer to take you, then you will
always say yes as it is easier.
2 Draw the Boolean algebra symbols for the following:
a) A NOT B
b) A AND B
c) A OR B
HELPFUL NOTES

In all logic gates except


Types of Logic Gate the NOT gate, there are
two inputs. The inputs or
There are three basic types of logic gate that will be examined in this chapter: NOT, AND and OR. outputs have two possible
states: a value of 1 or a
value of 0.

NOT AND OR
WORD ALERT

The left side of the logic gate is referred to as the input and the right side as the output. Referred: denoted /
identified.
We can use a truth table to show the function of the logic gate. Each of the logic gates has a different
truth table. These truth tables display all possible input combinations and the correct output.

Logic Gates and Circuits 143

SB CS PP.indb 143 14.5.21. 14:15


Chapter 10
NOT Gate
A X

DEFINITION The NOT gate takes a single input, A in the diagram above, and always produces the opposite of that
input in a single output, X.
Truth tables: used to
represent the Boolean Here is the truth table for the NOT gate above. It displays all possible combinations of inputs and the
expression of a logic gate corresponding outputs for the NOT gate. There are only two possible outputs for a NOT gate:  and .
or logic circuit.
Input Output

A X
 
 

Besides constructing truth tables, we can describe each gate using logic notation and
Boolean algebra. In this case the output is as follows:
Logic notation: X = NOT A
Boolean algebra: X = Ā

ENRICHMENT AND Gate


The total number of A
X
possible combinations B
can be obtained from
the formula C = 2n, where
C is the number of total The AND gate takes the inputs A and B and produces the output, X. If both inputs are , then the
possible combinations output will be , but otherwise the output will be .
and n is the number Here is the truth table for the AND gate above.
of inputs.
For example, if there
are three inputs, A, B Inputs Output
and C, the total possible
A B X
combination of inputs is
C = 23 = 8.   
  
  
  

Logic notation: X = A AND B


Boolean algebra: X = A·B
A and B show all possible combinations of inputs, so there are a total of four possible output states.

OR Gate
A
X
B

The OR gate takes two inputs, A and B, and produces output X. If either or both inputs is , the
output will be .

144 Logic Gates and Circuits

SB CS PP.indb 144 14.5.21. 14:15


Chapter 10
Here is the truth table for the OR gate above:
REFLECT
Inputs Output
A B X If someone asks you, ‘Do
you want a soda or some
  
water?’, you can’t answer
   ‘Both, please’. If you could
   have both that would be
   an inclusive use of OR. Is
the OR gate inclusive or
Logic notation: X = A OR B exclusive?
Boolean algebra: X = A + B
Out of the four possible output states, the only time output X will be  is when both the inputs
A and B are .
An inclusive OR is what is shown in the truth table if either A or B is True, or if both are True, then the
statement value is True.
An exclusive OR only returns True when A OR B is True only.

Worked Example
A security light outside a house comes on after .pm or if it is dark. Make a table showing WORD ALERT
the operation in normal language with corresponding Boolean and binary values. Make the
Condition: the state of
resulting truth table and choose the logic gate that will make this happen.
something in relation to
Solution its appearance, quality or
We have to state the conditions under which the light will come on: working order.
if it is after .pm
if it is dark
Then we convert these into the Boolean values ‘True’ and ‘False’:
it is after .pm = Yes/True/Positive
if it is dark = Yes/True/Positive
QUICK CHECK
Next we add the binary values:
it is after .pm Yes True Positive  In all logic gates except
it is dark Yes True Positive  the NOT gate, there are
two inputs. The inputs or
Then we make the truth table. The inputs are ‘it is after .pm and ‘it is dark’: outputs have two possible
states. What are they?
Inputs

it is after .pm it is dark

The light coming on is the output:

Inputs Output

it is after .pm it is dark the light comes on

Remember that the light will come on if either of the conditions is true:

Inputs Output
it is after .pm it is dark the light comes on
No No No
No Yes Yes
Yes No Yes
Yes Yes Yes

Logic Gates and Circuits 145

SB CS PP.indb 145 14.5.21. 14:15


Chapter 10
Finally, we can replace the normal language with binary and the inputs and output with letters:

Inputs Output
A B X
  
  
  
  
This is the truth table for the OR gate.

Activity
1 Now do the same for these situations. You can skip some steps if you don't need them.
• To save electricity and be ecological, an ‘up’ escalator will start moving when a pedestrian
steps near the bottom and breaks a sensor beam. Tip: there is only one input.
• A car park barrier will rise when a car approaches and the driver puts the ticket they have paid
for in a slot.
2 Name the logic gates represented by these truth tables:

a Input Output

A X
 
 

b Inputs Output

A B X
  
QUICK CHECK   
  
Write the Boolean algebra
expression for NOT, AND,   
OR gates.
c Inputs Output

A B X
  
  
  
  

HELPFUL NOTES

These three additional


Additional Logic Gates
logic gates look very In addition to the three logic gates shown above, there are also different versions of them: NAND, NOR
similar to 'AND', 'OR', 'NOT' and XOR.
with some slight changes.
Knowing the appearance
of the basic gates will
make remembering them
easier. NAND NOR XOR
Figure . NAND, NOR and XOR logic gate symbols

146 Logic Gates and Circuits

SB CS PP.indb 146 14.5.21. 14:15


Chapter 10
The NAND Logic Gate
A
X
B

You can see that the NAND gate has a small circle after an AND gate symbol. This means that it is like an
AND gate plus a NOT gate. The NAND gate functions like an AND gate but with the opposite output.
The NAND gate takes the input A and B and gives output, X. It will only give an output of  if both
inputs A and B are .
Here is the truth table for the NAND gate above:

Inputs Output

A B X
  
  
  
  

Logic notation: X = A NAND B


Boolean algebra: X = A·B
This means that the output X is always , unless both inputs A and B are  and then the output X is .

The NOR Logic Gate


A
X
B

Like the NAND gate, you can see that the NOR gate has a small circle after an OR gate symbol.
This means that it is like an OR gate plus a NOT gate.
The NOR gate takes the input A and B and produces an output of  if both inputs A and B are .
Here is the truth table for the NOR gate above.

Inputs Output

A B X
  
  
  
  

Logic notation: X = A NOR B


Boolean algebra: X = A+B
The output X is always , unless both inputs A and B are  and then the output X is .

Logic Gates and Circuits 147

SB CS PP.indb 147 14.5.21. 14:15


Chapter 10
The XOR Gate
A
X
B

The XOR gate (which means ‘exclusive OR gate’) is similar to the OR gate, except that if both inputs
are  then the output is . The XOR gate has a different logic outcome to the OR gate: the output X is
 when either (but not both) of the A or B inputs is .
Here is the truth table for the XOR gate above:

HELPFUL NOTES Inputs Output


In Boolean algebra, the A B X
symbol for ‘exclusive OR’ is
  
a ‘+’ inside a circle:
  
  
ENRICHMENT   
Logic notation: X = A XOR B
You have now looked at
six logic gates. There are Boolean algebra: X = A B or X = (A·B)+(A·B)
actually seven – can you
This also means that the output is  when both inputs A and B are  or .
find the other one?

Worked Example
Two people are walking towards each other along a corridor wide enough for two people to
pass. On one side of the corridor there are windows and on the other there is a blank wall.
Find the gate that describes the conditions where they can pass without bumping into
each other.
Solution
QUICK CHECK The inputs are:
Person  = A
Draw the logic gates for Person  = B
NAND, NOR, XOR. And the values are:
Near the window = True
Not near the windows (near the wall) = False
Result
If both walk near the wall obviously, they can’t pass.
If A walks near the window and B near the blank wall, they can pass.
If B walks near the window and A near the blank wall, they can pass.
If both walk near the windows, they can’t pass.
REFLECT The truth table looks like this:

What would happen if we


used an inclusive OR gate
Inputs Output
to describe this situation?
A B X
Why do we need different
symbols for inclusive and   
exclusive OR?   
  
  

This is the table for the XOR gate. The XOR gate is an exclusive OR gate. If both inputs are true
then the output is false.

148 Logic Gates and Circuits

SB CS PP.indb 148 14.5.21. 14:15


Chapter 10
Activity
1 Now do the same for this situation. You can skip some steps if you don’t need them.
Tip: the circuits are normally on so something needs to happen if they go off.
QUICK CHECK
• An alarm makes no warning sound if the door is closed and the window is closed. There are
hidden switches on the door and window through which a current is constantly passing. If Write the Boolean algebra
someone opens the door or window, the alarm sounds. expression for NAND,
2 Name the logic gates represented by these truth tables: NOR, XOR.

a Inputs Output
A B X
  
  
  
  

WB LINK
b Inputs Output
Consolidate your
A B X understanding by
   completing the Exercises
   1-2 from pages 123-129
in the Workbook.
  
  

Logic Gates and Circuits 149

SB CS PP.indb 149 14.5.21. 14:16


Chapter 10

. Combining Logic Gates


Basic logic gates can be combined together in a certain way to get different outputs. These allow for
complex operations to be carried out, for example, controlling a processing unit.
WORD ALERT
The combination of two or more logic gates forms a logic circuit.
Complex: more difficult Just as individual gates have truth tables, logic circuits have their own, more complex, truth tables.
/ more components
involved.
Logic Circuits
Worked Example
REFLECT Examine the truth table for this logic circuit, below.
Create your own logic B P
circuits using the AND, OR X
and NOT gates.
A
Draw the corresponding
truth tables. Input Intermediate output Output
A B P = A AND B X = NOT (A AND B)
   
   
   
   
Solution

A P
X
B
HELPFUL NOTES

When combining logic Part  Part 


circuits it is often easier
to break them down into We can see that Part  of the circuit is an AND gate. The intermediate output is at P. Part  of the
smaller sections. circuit is a NOT gate, and therefore X = NOT P.
The truth table can then be constructed as follows:

Input Intermediate output Output


A B P = A AND B X = NOT P
LINK WB    
Consolidate your    
understanding by    
completing Exercise 2 in    
the Workbook, page 127.
If we look at only the initial inputs A and B and the final output X, the truth table becomes:

Inputs Output
A B X
  
  
  
  
This is also known as a NAND gate, which was discussed above.

150 Logic Gates and Circuits

SB CS PP.indb 150 14.5.21. 14:16


Chapter 10
Activity
ENRICHMENT
Make this logic circuit into a table that shows the intermediate outputs and the final outputs and
that has the same function as the NOR gate. Create revision cards on
the rules for each of the
six logic gates we have
discussed.
A P
Gate? X
B

Part  Part 

Inputs Intermediate output Output

A B P X
  ? 
  ? 
  ? 
  ? 

Logic Circuits with More Than Two Inputs


A logic circuit with three inputs is known as a two-level logic circuit.
The more inputs in the logic circuits, the more possible combinations there are. For example, if there
are three inputs and each one can take two values ( or ), then  ×  ×  =  rows will be required.

A
B P
X
Q REFLECT
C
Do you think it is cheaper
to use simple logic
Break down the logic circuit into sections. circuits like this AND
gate and NOT gate or to
1 Work out P by completing the OR gate: find a single gate that
P = A OR B will perform the same
function, such as a NAND
This can then be added to the P column in the truth table below. gate?

A P
B

Logic Gates and Circuits 151

SB CS PP.indb 151 14.5.21. 14:16


Chapter 10
2 Work out Q by completing the NOT gate.
Q = NOT C
This can then be added to the Q column in the truth table below.
HELPFUL NOTES
Q
If is often the case that C
intermediate outputs do
not continue as
D, E, etc., but begin a new
sequence as shown here. Input Intermediate outputs Output
This does not change the A B C P = (A OR B) Q = (NOT C) X = (A OR B) AND (NOT C)
logic behind each gate or
logic circuit.      
     
     
ENRICHMENT      
     
Can you write the output
in Boolean algebra?
     
     
     

WORD ALERT Worked Example


Detects: identifies. We already have a fire alarm that sounds in the building when the circuit detects heat and
smoke. However, we need a special alarm that will directly alert the fire service if there is no-one
in the building. This system uses three inputs to a logic circuit. The alarm X will sound if inputs A
(smoke) and C (heat) are both on, and where input B (motion detector) is off.
Design a logic circuit and make a truth table to show when the fire alarm will sound;
i.e. where X = .
Solution
To show the conditions where X =  we must write the logic statements that represent
this situation.
X= , if (A =  AND B = ) AND (C =  AND B = )

To explain this a little further:


(A =  AND B = ) means A is ON and B is OFF
(C =  AND B = ) means C is ON and B is OFF
In Boolean algebra, we can write this as X = (A·B)·(C·B).
The logic circuit can be made up of Part  (A·B), which is (A =  AND B = ) as follows:

152 Logic Gates and Circuits

SB CS PP.indb 152 14.5.21. 14:16


Chapter 10
Part  (C·B), which is (C =  AND B = ):

If we combine Parts  and , we get the circuit below:

REFLECT
C
Draw a combined
logic gate circuit which
To complete the circuit, we combine Parts  and  with the AND gate: includes a NAND gate and
create the corresponding
completed truth table.
A P

R
B X

C Q

The truth table can be constructed as follows:

Inputs Intermediate outputs Output

A B C R P Q X
      
      
      
      
      
      
      
      

Logic Gates and Circuits 153

SB CS PP.indb 153 14.5.21. 14:16


Chapter 10

Activity
Draw a truth table for this logic circuit:

A P

HELPFUL NOTES R
B X

Add all possible input


combinations into
the truth table first.
C Q
Then decompose each
problem into smaller
sections to help complete
the intermediate outputs.
Writing Logic Circuit Statements
You will need to be confident in writing and understanding logic statements. This logic circuit is for
an AND gate.

B
X
A

The AND gate logic circuit statement is written as X = A AND B. You can use these statements to
draw the corresponding logic circuits.
Logic gates can be combined to make more complicated circuits, such as this one below:

Worked Example
A P
X
B

Work out the logic statement for this circuit.


Solution
Start at the final output, X. The X output depends on its inputs. X = NOT P
P is an intermediate output, so we have to break it down into a mini P = (A OR B)
problem and put that into brackets. The P output depends on its
inputs.
Now our logic statement only has the final output and the first inputs, X = NOT (A OR B)
so we know it is complete.

154 Logic Gates and Circuits

SB CS PP.indb 154 14.5.21. 14:16


Chapter 10

Activity
Work out the logic statement for this circuit:

A
B
P
X
Q
C
D

Figure 7.2 Combined logic circuit with four inputs.

Start at the final output. The output of X depends on its inputs. f


P is an intermediate output. Break it down and put it in
brackets. The P output depends on its inputs.
Q is also an intermediate output. Break it down and put it in
brackets. The Q output depends on its inputs.
Final output and the initial inputs

Drawing Combined Logic Circuits using Statements


HELPFUL NOTES
You can draw a logic circuit directly from a logic statement. You may need to go back and revisit the
logic gate symbols first. For example, the logic circuit for the statement X = (A OR B) AND C is as follows: When converting a
circuit into a statement,
A P always start from the
final output and work
B X backwards . Convert each
C
intermediate output
into its inputs. When you
This is possible by breaking down the statement and working through each stage.
have only the first input
X = P AND C f on the left and the final
output on the right in
P = (A OR B) your statement, you have
X = (A OR B) AND C completed the table.
Remember to check you
have the right gates and
Worked Example the correct number of
inputs.
We can also produce a circuit from a statement. For example, a car’s wipers will operate only
when the engine is on, the car is moving and the windscreen sensor is sensing rain.
There are three input conditions:
• the engine is on
• the car is moving
• the windscreen sensor is sensing rain
Solution
Let’s call them A, B and C.
The output is that the car’s wipers operate. This is X. We have to reduce three inputs to X for the
final gate. We do this by combining two inputs into one, like this:
X = A AND (B AND C)

Logic Gates and Circuits 155

SB CS PP.indb 155 14.5.21. 14:16


Chapter 10
The resulting logic circuit is this:

LINK A
B X
Consolidate your C
understanding by
completing the Exercises
3-4 from pages 129-133 The truth table is this:
in the Workbook.
Inputs Intermediate outputs Output

A B C B AND C X
    
    
    
    
    
    
    
    

Activity
A photocopier has two options for putting in paper to print: a place to slide in a single sheet of paper
and a multifeed drawer for a stack of paper. If there is paper in either of these places and we press
the start button then the photocopier will work. Make the logic statements to describe this scenario
and then draw the resulting logic circuit and truth table for the entire circuit.

ENRICHMENT
Logic Circuits in Use
Can you think of other
logic circuits in use? In practice, logic gates are often built up using a combination of NAND gates.

NOT A X

A
AND X
B

OR X
B

156 Logic Gates and Circuits

SB CS PP.indb 156 14.5.21. 14:16


Chapter 10

NOR X
B

XOR X

Worked Example REFLECT

Show that the circuit below is logically equivalent to the NOT gate. Why do you think the
NAND gate is often called
the ‘universal’ NAND Gate?
A X

Solution ENRICHMENT

What careers/job roles do


Inputs Output you think require the use
of logic circuits?
A A X
Explain examples of
   when these job roles
   would have to use
this knowledge when
From the results given in the truth table, we can see that the truth table is logically equivalent to carrying out their work.
the NOT gate, and the output X is the inverse of the two inputs of A.

Activity
Show that the circuit below is logically equivalent to the AND gate.

A
X
B

In your home and in everyday life, there are many electrical items and appliances that rely on logic
circuits in order to function.
Consider the following scenario.
• In order for an elevator to travel to the correct floor, someone must have pressed a floor number
button inside the elevator and the doors must be closed.
• The total weight in the elevator must also be under the limit (false, , negative).
• The elevator moving = X (positive, , true).

Logic Gates and Circuits 157

SB CS PP.indb 157 14.5.21. 14:16


Chapter 10
The logic circuit for the scenario would look like this:
A
B P
X
Q
C

And the logic statement would be:

X = (A AND B) AND (NOT C)


And the truth table would be as follows::

Inputs Intermediate outputs Output


A B C P= (A AND B) Q = (NOT C) X
     
     
     
     
     
     
     
     

Writing logical expressions from Truth Tables


You can use a Truth Table to create the logical expression and create the logic circuit.
Using the Truth Table below where X is the output, we can see that both A and B need to be ON for
the output X to be ON. This tells us that the logic gate it is representing is the AND gate.
Look at each row and where the output (X) is ON () you look at the inputs (A and B).
• If the input is ON () then the input is written as the letter: A
• If the input is OFF () then the input is written as the letter with a line above it: A

A B X

  
  
  
   AB

158 Logic Gates and Circuits

SB CS PP.indb 158 14.5.21. 14:16


Chapter 10
In the example above the output is ON () on the last row and both inputs are ON ().
• The logical expression would be written as X = A AND B
Notice that everything is in capitals, this is expected when writing logical expressions.
We can then draw the logic gate to represent the truth table and logical expression.
A
X
B

More than  inputs


Looking at the example below we can see the Truth Table shows an A, B and C input and an output X.

Inputs

A B C X

   
   
   
   
   
   
   
   

Look down the X column and circle where the output is ON ().
On each row where the output is ON (), use the method to note down which inputs are ON () and
OFF ()
The first row would be written as A B C

Inputs

A B C X .

    A B- - C
   
   
   
    ABC
   
    ABC
   

Logic Gates and Circuits 159

SB CS PP.indb 159 14.5.21. 14:16


Chapter 10
Row Notes on inputs Logical expression for row

 ABC NOT A AND NOT B AND NOT C


LINK WB  ABC A AND NOT B AND NOT C
Consolidate your  ABC A AND B AND NOT C
understanding by
completing Exercise 5, Each part is placed within brackets and placed together with OR written between each.
page 133 in the
Workbook.
The logical expression for the Truth Table would be:
X = (NOT A AND NOT B AND NOT C) OR (A AND NOT B AND NOT C) OR (A AND B AND NOT C)

160 Logic Gates and Circuits

SB CS PP.indb 160 14.5.21. 14:16


Chapter 10
7

Let’s Map It
Truth tables
Logic gates
have logic Truth tables are used to represent
Boolean values
states given by: the Boolean expression of a logic
LOGIC Boolean Binary Synonyms which are used
gate or logic circuit.

GATES value
True
value
 On Yes Positive
in truth tables: A
B
X

False  Off No Negative


Inputs Output
A B X
  
  
  
  

and in the different types of logic gates:


COMBINING
LOGIC Types of gates

GATES
NOT AND OR
Input Output Inputs Output Inputs Output
A X A B X A B X
       
Using Boolean
       
algebra:      
     

Boolean algebra

A NOT A A+B A NAND B XOR NAND NOR

A+B A and B A+B A NOR B Inputs Output Inputs Output Inputs Output
A B X A B X A B X
A+B A OR B A B A XOR B         
        
and by         
combining         
different logic All have 2 inputs except for 'NOT' gate
gates:

Combining logic gates

B P
X
A

Inputs Intermediate Output


output
A B P X
    Examples of logic circuits
    used in the real world
   
    -Security alarms
-Elevators
We can write -Eletrical circuits
logic statements eg light switches
for logic circuits: -Bank vaults

Logic statements
Break down the X = (A AND B) OR C
statements always
start with the A P
output AND
B
OR X

Logic
LogicGates
gates and
and Circuits
circuits 161
31

SB CS PP.indb 161 14.5.21. 14:16


Chapter 10

Let’s Review
 What logic gate matches these truth tables?

A B X A B X

     
     
     
     

 Label the following logic gates:

 Draw the logic circuit for the following statement X = (A AND B) AND (NOT C).
 Complete a combined truth table including any intermediate outputs for the following: <?>

A P
AND
B
OR X

C
 Draw the correct logic gate circuit and truth tables to match these Boolean algebra expressions:
A˙B A+B Ā
 Draw the logic circuit diagram and corresponding truth table represented by the below Boolean algebra epressions.
Consider the logic statement:
X =  If [(A is NOT  OR B = ) NAND C is ] NOR [(A is  AND C is ) NAND B is ]

B X

A B C Working space X
  
  
  
  
  
  
  
  

162 Logic gates and circuits

SB CS PP.indb 162 14.5.21. 14:16


Answers
Answers to Let’s Review Sections  Both methods enable the full use of bandwidth in
communication
Chapter 
 Data cannot be sent simultaneously
 Binary is a base- number system ( digits); Denary is
 Universal Serial Bus
a base- number system ( dgits); Hexadecimal is a
base- number system ( digits)  Any three sensible answers, including mouse, printer,
keyboard, hard disk drives, mobile devices
 Accept either  or 
 Some packets of data could be lost, or some digits
 
could be changed
 Right to left
 Odd or Even
 Accept any correct method of working where the
 False
answer runs as follows:
 A check digit is calculated using all of the other digits
 -  – F
in a barcode and, if the code is correct, the check digit
 Accept any correct method of working where the should match
answer runs as follows:
 A timeout is where a receiving device is waiting for
D –  – 
a response and, once the timeout occurs, a repeat
 Any three from: MAC addresses, error codes, HTML request is made for the acknowledgement of the
colour codes and IPv addresses expected data
 Accept either  or  =  (Denary)  False
 Accept either  or  =  (Denary)  Encryption is important to stop unauthorised users
 The ‘most significant bit’ intercepting and accessing sensitive data when it is
 The decimal part of the number is discarded being transmitted across a network
 The use of two’s complement Chapter 
   Architecture is the components that make up a
  computer system
 American Standard Code for Information Interchange,  The CPU processes the instructions and data given by a
a character set used most commonly by computer user through the input devices
systems –  characters  The Memory Address Register; Memory Data Register;
 A kilobyte represents  bytes, a kibibyte represents Accumulator; Program Counter; Current Instruction
 bytes – a kibibyte is calculated by powers, whereas Register
a kilobyte is calculated by multiplying whole numbers  The von Neumann architecture is based upon an
together input device feeding data into a CPU, with a memory
 Accept .Kb or .Kb unit reading data in and out of the CPU. The result of
processing is then sent to an output device
 Lossless compression – file sizes are reduced but there
is no loss of data, duplications are removed instead  Fetch – Decode – Execute
Lossy compression – data is permanently removed  Buses are connections that carry data around a
from a file to reduce its size, such as bits of music or computer
images  Cache memory sits within a CPU and holds instructions
Chapter  and data that are needed regularly. Cache memory
allows quicker access to these instructions and data
 A small chunk of data designed to be sent around a
leading to faster processing
network
 Dual-core
 Packet header, payload and trailer
 Hertz, also accept gigahertz
 The trailer tells the receiving device that it has reached
the end of the transmission. It is a validation check  Any sensible example: dishwasher, GPS, sat-nav, central
heating, calculator, vending machine, lighting system,
 This is where a transmission of packets travels along a
CCTV
network and takes different routes. Data is transmitted
by the most suitable route  A capacitive touchscreen allows multiple touch
sensing, a resistive touchscreen only allows one touch
 Serial transmission is where one bit at a time is sent
due to using the pressure change, and infra-red works
between devices, parallel transmission sends multiple
on the basis of breaking a beam of light and is much
bits of data through multiple channels
more sensitive

Answers 163

SB CS PP.indb 163 14.5.21. 14:16


 Either a moisture or level sensor would be acceptable Chapter 
answers  The internet is the network of computers connected
 Cloud storage is when a user purchases some space on together as a set of small networks to enable
an external server, accesses it via the world wide web communication to occur. The world wide web is the
and can download from and upload to the space when collection of websites and web pages stored on servers
required that are accessed through the internet
 A MAC address is a unique identifier for a piece of  Uniform Resource Locator
equipment connected to the internet, the IP address  Secure hypertext transfer protocol
is the location identifier that enables devices to
 Any three from: displaying websites, bookmarks and
communicate with one another
favourites, recording user history, multiple browsing
 These are issued by a router using a service called tabs, storing cookies, navigation tools and an address
DHCP, and are not specific to a device bar
 A router is a device that enables a home or business to  Domain Name System
connect devices to the internet
 The DNS Query uses the URL that has been entered by
Chapter  the user and looks up the matching IP address. The IP
 Any two of: the BIOS, utility software and the operating address then connects the user’s browser to the web
system server that hosts the site and retrieves the required
website for the user to view
 Any three of: managing peripherals, drivers, files,
multitasking, memory or handling interrupts  Session and persistent cookies
 Small applications which enable a computer to start all  Any two of: cookies can store items in a shopping
of its devices basket for later, store preferences about how a website
loads, store login details or allow targeted adverts to
 An intervention from a user
appear
 Software and hardware interrupts
 Any two of: Ethereum, Tether or Litecoin
 Either a division by zero or a process attempting to use
 Blockchain is a database containing digital records of all
the same memory location
cryptocurrency transactions
 Low level programming language is machine or binary
 Any three of: brute-force attack, data interception,
code. High level programming languages use words
DDoS attack, hacking, malware, pharming, phishing,
that we use as humans
 Malicious software that causes damage to a computer
 It is easier for programmers to debug high level code
system
 Assembly language is similar to machine code but
 Pharming is where a user is sent toa fake website that
it uses mnemonics for instructions and commands
looks genuine; phishing is where an email is received
alongside numbers
that looks genuine but contains links to malicious
 A compiler and an interpreter websites
 A compiler will run an entire block of code and  Where users are manipulated into behaving in a way
produce a list of errors and is best used at the end of a that they would not normally do
programming project. An interpreter will execute code
 This allows security loopholes to be closed and security
line by line
databases for anti-virus software to be kept up to date
 It is better for debugging and finding problems as the
 It enables browsing of the world wide web while
interpreter will stop when it finds an error
keeping an IP address secret
 Integrated Development Environment
Chapter 
 Any two functions from: code editing, auto-completion
of syntax, auto-correction of common errors, code  Sensors, a microprocessor and actuators
formatting, translation of code, error diagnosis and  Actuators turn electrical signals into physical
simulation in a run-time environment movements
 Any sensible answer, for example automated motorway
signs that control the flow of traffic
 A danger of creating a fictional life where a user spends
more time rather than their real life
 A factory robot on a production line, a domestic robot
that operates in the home or an airborne robot like a
drone

164 Answers

SB CS PP.indb 164 14.5.21. 14:16


 A mechanical structure or framework, and electrical  A trace table enables a programmer to work through
components, like sensors, microprocessor and the code on paper, line by line, to check where
actuators variables, selection, sequencing and iteration take
 Any sensible example, such as a scanner in a CT place
scanning machine  A syntax error
 They can carry out jobs without humans needing to be  Any reasonable error, such as incorrect use of an
present arithmetic or Boolean operator
 Artificial Intelligence Chapter 
 Expert Systems and Machine Learning  A variable piece of data can be changed in some way,
 Any reasonable explanation, such as: A user would either by the user or the program
type a word into the user interface and select the  Any two from: integer, real, char, string or Boolean
language of translation. The software would use the
 The sequence determines the order that a set of
inference engine to determine what was required and
instructions are carried out
would then draw upon its knowledge base to provide
a solution. The translation may also utilise the rules  An IF statement
base and explanation system to also provide possible  Count-controlled, pre-condition and post-condition
alternatives to the translated word, based on similar loops
searches previously carried out by other users  A counter is used to know how many times the
Chapter  iteration has occurred
 Analysis – Design – Coding – Testing  Changing them into upper or lower case
 Abstraction is the process of selecting the information  Any three from: subtraction, division, raise a power,
in a problem and focusing only on the important parts MOD or DIV
of that information. During abstraction, any detail that  Does not equal
is irrelevant to the problem is ignored  AND - If something and something else are true or
 Decomposition is breaking down a complex problem false; OR - If something or something else is true or
into small manageable pieces. It is where a problem false; NOT - If something is NOT true or false
becomes a series of small tasks that can be handled first  Where it is necessary to execute one IF statement,
individually and then collectively as part of the bigger followed by another, followed by another. This would
program form a subroutine, with each routine nested inside
 A decision, usually a yes/no answer another
 False  Where a function or procedure sometimes requires a
 Structure diagrams are different from flowcharts in that programmer to give them additional information to
they display the different levels of detail within a set of carry out their processes
decomposed problems  A global variable is generally declared at the start of
 All items of data in a set are looked at until the program a program and can be used anywhere throughout a
matches the piece of data it is looking for. Once this program. A local variable is declared within a function
match is obtained, the search is completed. In a large and can only be used within the function
data set this would take a long time  Any two from: MOD, DIV, ROUND, RANDOM
 A data set that has not yet been sorted into a particular  All identifiers should be easily recognisable by
order programmers to ensure the code can be easily read
 A bubble sort is based upon the idea of swapping and understood
adjacent items in a data set until the set is in a desired  Commentary can be very helpful to know what a
order programmer or developer was thinking at the time
 Any three answers from: range check, length check, of writing a particular line or set of lines of code, and
presence check, format check, check digit any programmer working in a team would be able to
access other people’s coding much more easily. They
 Double-entry checking
are not executed
 The process of testing reports any errors to the
 A set of related data that are all of the same data type
programmers and the testing is repeated until there are
no errors found in the system  False
 This data includes the extreme values of the normal
range given, as the highest possible and lowest
possible data in a set

Answers 165

SB CS PP.indb 165 14.5.21. 14:16


 It is often important to store program data in external  Practical task - answers may vary
files so that it is not lost when a program has finished  Practical task - answers may vary
running. Programming can often take weeks and
months to create, and to be constantly restoring data Chapter 
to code would be hugely time consuming
 False
 OR gate
Chapter 
 A database is an organised collection of data. It is
electronically stored and accessed in a computer
system

NAND gate
Flat-file database Relational database
A flat-file database stores A relational database can have
simple data formats. They multiple related tables. 
store only a single table of When the tables are linked,
data. the user can work on complex
The information given by a data structures having
record is complete with a multiple tables.
fixed number of fields. A relational database does not
Thus, the database is not allow data duplication. Also, it
related to any other table or is more efficient and NAND gate NOR gate XOR gate
database. consistent than a flat-file
This method of storing data database.  The logic circuit for the scenario would look like this:
is not efficient and may
lead to problems like data
duplication, data redundancy
and input errors.

 Queries are used for working with data in a database.


These are requests that help in arranging, retrieving or
modifying information from a database.
Example of statement that can be used to retrieve data
using SQL queries:  X = P OR C
SELECT [Field Name] FROM [Table Name] P = A AND B
 A data type is an attribute or property of a field X = (A AND B) OR C
in a database which helps in helps the computer The truth table is:
to identify similar data for the purpose of sorting,
Input Intermediate outputs Output
searching and calculation. For example, Text, Char,
Integer, Number, etc. A B C A AND B X

 Practical task - answers may vary 0 0 0 0 0

 Validation refers to checking and confirming the 0 0 1 0 1


accuracy of data or information in the computer 0 1 0 0 0
system. There are certain rules that are followed when 0 1 1 0 1
data is typed into a database system called the data
validation rules. For example, a phone number does 1 0 0 0 0
not contain a character or an alphabet. These rules help 1 0 1 0 1
in accepting the data which are as per the set format. 1 1 0 1 1
The data entered into a database can sometimes be
1 1 1 1 1
entered incorrectly. It can be invalid, inconsistent or
incomplete. To avoid any such issue, the user may apply
different validation checks. Some validation checks are:
Presence check, Range check, Length check and so on.

166 Answers

SB CS PP.indb 166 14.5.21. 14:16


 A . B represents AND gate, that is, A AND B  The corresponding circuit diagram is:
The corresponding Logic gate and circuits are:

The truth table is:


Input Intermediate outputs Output
A B C P=Ā Q=P R=Q S=A T=B X=R
OR B NAND C AND C NAND S NOR T
0 0 0 1 1 1 0 1 0
0 0 1 1 1 0 0 1 0
A + B represents OR gate, that is, A OR B
0 1 0 1 1 1 0 1 0
The corresponding Logic gate and circuits are:
0 1 1 1 1 0 0 1 0
1 0 0 0 0 1 0 1 0
1 0 1 0 0 1 1 1 0
1 1 0 0 1 1 0 1 0
1 1 1 0 1 0 1 0 1

represents NOT gate, that is, NOT A


The corresponding Logic gate and circuits are:

Answers 167

SB CS PP.indb 167 14.5.21. 14:16


Index
A biometric authentication 77 pharming 74
abstraction 95 BIOS (Basic Input Output System) 60 phishing 74
Access 132–133 bit (binary digit) 15 social engineering 74
access levels 74 bit depth 15 solutions 74–80
accumulator 36 bit rate 15
D
actuators 48, 84, 85 Blu-ray discs 53
data 128
address bar 29, 68, 69, 70 bookmarks 70
abnormal 105
address bus 36, 37 Boolean algebra 142–143, 144, 145,
corruption 27
adware 73 147, 148
types 112, 129
AI (artificial intelligence) 88–90 Boolean data 112, 130
data bits 3
algorithms 28, 94, 100–101, 114 Boolean operators 107, 119, 142
data bus 36
flowcharts 97–98 boundary data 105
data compression 18
iteration in 115 browsers 70
data entry, validation and verification
pseudocode 98–99 brute-force attack 72
104–105
solution methods 101–103 bubble sort 101–103
data interception 72
structure diagrams 99–100 buses 36
data storage 15–17, 50–53
trace tables 105–107 bytes 5, 15, 16
data transmission 22–27
writing 108
C full-duplex 25–26
ALU (arithmetic logic unit) 35, 37
cache memory 38 half-duplex 25
analogue signals 14, 44
cameras 43 methods of 23–26
AND gate 143, 144
capacitive touchscreens 43 parallel 24
AND operator 119
capacitors 52 serial 23–24
application software 60
CASE statements 114–115 simplex 24
running sequence 61
CD (compact disc) drives 53 vis USB 26–27
arithmetic operators 118
Character/Char, data type 112, 129 databases 128–130
ARQ (automatic repeat requests) 28
check digits 28–29, 104 creating 131–134
arrays 122–123
checksum 28 data types 129
ASCII code 13
clock speed 38 data validation 133–134
assembly language 63
cloud storage 54 entering data 134
authentication 75–78
code editor 64 queries 129, 135–137
biometric 77
comments, in computer programs tables 129, 132–133, 134
electronic tokens 78
121 types of 130–131
magnetic stripes 77
compilers 63–64 uses 128
passwords 75–76
computer architecture 34–36 date/time, data type 130
physical tokens 78
computer systems 60, 97–100 DBMS (Database Management
smart cards 77
embedded 39 System) 130
spyware 76
OS (operating system) 60 decomposition 95
zero login 77
constants 112 DEFAULT output 115
auto-completion 64
control bus 36 denary (base-10) numbers 2
auto-correction 64
control unit 35 converting to binary 3–4
automated systems 84–86
cookies 70, 71 converting to hexadecimal 5
automating software updates 78
COUNT function 137 dictation software 44
AutoNumber 130
count-controlled loop 115, 116 digital currency 72
AVERAGE 103
counting 103, 117 digital light processing (DLP)
B CPU (central processing unit) 34 projector 46
barcode processing cores 38 Distributed Denial of Service (DDoS)
check digits 28 cryptocurrency 72 attack 73
reader 44 currency, data type 130 DIV (division) 118, 121
binary numbers 2–3 current instruction registers 36 Domain Name System (DNS) Query
adding two binary numbers 7–8 cyber security 72–80 71
converting to denary 4 brute-force attack 72 double entry 105
dividing 10 data interception 72 DO-WHILE iteration 116
multiplying 9 DDoS (Distributed Denial of Ser- dual-core processor 38
overflow errors 8–9 vice) attack 73 DVD (digital versatile disc) drives 53
binary shifting 9 hacking 73
with 8-bit binary numbers 10–11 malware 73

168 Index

SB CS PP.indb 168 14.5.21. 14:16


E information 128 MAR (memory address register) 36
echo check 28 infra-red screens 43 MAXIMUM 103
electronic tokens 78 inkjet printers 47 MDR (memory data register) 36
embedded systems 39 input 113 measurement units 16
encryption 29–30 input devices 40–45 memory 50
asymmetric 30 instruction sets 38–39 memory unit 36
symmetric 30 integers 112, 129 microphones 44
error detection 27–29 internet 68–71 microprocessors 49, 84, 85
and correction 107–108 interpreters 63–64 MINIMUM 103
error diagnostics 64 interrupt service routine 61 MOD (modulo) 121
executable files 63 interrupts 61–62 modems 56
expert systems 89 IP (Internet Protocol) address 22, monitors 45
extreme data 105 55–56 mouse 41
ISBN numbers, check digits 28 mp3 files 18
F
iteration 115–116, 120
favourites 70 N
fetch-decode-execute cycle 37 J NAND (NOT AND) logic gate 52, 146,
fields, in a database 129 JavaScript 63 147
file handling 123–124 jpeg files 18 nested statements 119–120
files iteration 120
K
reading from 124 selection 119
keyboard 40
writing to 124 network hardware 54–56
kibibytes (KiB) 16
firewalls 79–80 nibbles 15
flash drives 52–53 L non-volatile storage 51
flat-file (single-table) databases 130 LAN (local area network) 56 NOR (NOT OR) logic gate 52, 146, 147
flowcharts 97–98 laser printers 47 normal data 105
FOR loop 116 LCD (liquid crystal display) monitors NOT Boolean operator 119
foreign key 130 45 NOT logic gate 143, 144
format check 104 LCD (liquid crystal display) projectors number systems 2–3
fragmentation 51 46 numbers/numeric data 129
full-duplex data transmission 25–26 LED (light emitting diode) screens 45 numeric keypads 40
functions 120, 121 length, of a string 117
O
length checks 104
G opcodes (operation codes) 38
library routines 121
gaming controllers 41 operands 39
linear search 101
global variables 121 optical character recognition 43
local variables 121
optical disc drive 53
H logic circuits 150–158
OR Boolean operator 119
hacking 73 drawing 155–156
OR logic gate 143, 144–146
half-duplex data transmission 25 with more than two inputs
ORDER BY clause 137
hardware interrupts 62 151–154
OS (operating system) 60–61
HDMI (high-definition multimedia using 156–158
output 113
interface) 46 writing statements 154–155
output devices 45–48
hertz 15 logic errors 107
overflow errors 8–9
hexadecimal numbers 3 logic gates 142–149
converting to denary 6 combining 150–158 P
uses in data representation 6–7 types of 143–149 packet switching 22–23
HTML (hypertext markup language) logical operators 118–119 packets, structure 22
70 lossless data compression 18 parallel data transmission 24
HTTP (hypertext transfer protocol) 69 lossy data compression 18 parity check 27–28
https (secure hypertext transfer LOWER 118 passwords 75–76
protocol) 69 pen drives 52–53
M
pharming 74
I MAC (media access control)
phishing 74, 79
IDE (Integrated Development addresses 55
pixels 15
Environment) 64 machine code 62
pointing devices 41–42
IF, THEN, ELSE 114 machine learning 90
portable magnetic hard drives 52
IF statements 114 magnetic hard disk drives 51–52
portable solid state hard drives (SSDs)
image files, calculating the file size magnetic stripe cards 77
52
of 16 malware (malicious code software) 73
post-condition loops 115, 116
image representation 15 anti-malware software 74–75
pre-condition loops 115, 116

Index 169

SB CS PP.indb 169 14.5.21. 14:16


presence checks 104 S trojan horse 73
prettyprint 64 sample rates 15 truth tables 143
primary key 130, 133 SATA (serial advanced technology two’s complement 11–13
primary storage 50 attachment) cable 51 type checks 104
printers 47–48 scanners 43
U
privacy settings 80 secondary storage 50, 51–53
Unicode 14
procedures 120–121 SELECT statement 137
units of measurement 16
processing core 38 selection 114
UPPER 118
program counter 36 sensors 49, 84, 85
URL (Uniform Resource Locator)
program development life cycle 94–96 sequencing 114
68–69, 79
analysis 94–95 serial data transmission 23–24
USB (Universal Serial Bus) 26–27
coding and iterative testing 96 simplex data transmission 24
user history 70
designing 95–96 smart cards 77
utility software 60
testing 96 social engineering 74
programming software 60–62 V
concepts 112–122 application 60, 61 validation checks
creating programs 121–122 automating updates 78 for data in databases 133–134
fundamentals 114–119 OS (operating system) 60–61 for programs 104
programming languages 62–64 software interrupts 62 variables 112
high-level and low-level 62 solution methods 101–103 in computer programs 121
proxy servers 80 sound files, calculating the file size of 17 global 121
pseudocode 97, 98–99 sound representation 14–15 local 121
Python 63, 94, 108, 112, 113 speakers 48 verification 105
arrays 122 spelling errors, in phishing emails 79 video conferences 43
functions 120 spyware 73, 76 virtual memory 53
iteration 116 anti-spyware software 74–75, 76 viruses 73
nested selection 119 SQL (Structured Query Language) 135, anti-virus software 74–75
reading from a file 124 136–137 visual checks 105
string handling 117–118 SSD (solid state hard drives) 52 von Neumann, John 35
totalling and counting 117 SSL (secure sockets layer security
W
writing to a file 124 protocol) 80
web address see URL (Uniform
standard solution methods 103
Q Resource Locator)
strings 112, 117–118
QR (quick response) scanner 45 web browsers 70
structure diagrams 97, 99–100
quarantine 75 web pages 71
stylus pens 41
queries, database 129, 135–138 webcam (web camera) 43–44
substring 117
query-by-example 135–136 WHERE clause 136
SUM function 137
WHILE loop 116
R symmetric encryption 30
world wide web 68
RAM (random access memory) 36, syntax errors 107
worms 73
50, 53 system security 61
writing to a file 124
RANDOM 121 system software 60
range checks 104 X
T
ransomware 73 XOR gate 146, 148
tables, in a database 129
reading from a file 124
testing programs 105 Z
real numbers 112, 129
text representation 13–14 Zero login 77
records 129
text/alphanumeric data 129
registers 35–36
three-dimensional (3D) printers 48
relational databases 130
tokens 78
resistive screens 42
totalling 103, 117
robotics 87–88
touch screens 42, 46
ROM (read only memory) 50
touchpads 41
ROUND 121
trace tables 105–107
routers 56
trackballs 41
run length encoding (RLE) 18
transistors 3, 52
run-time environment 64
translators 63, 64

170 Index

SB CS PP.indb 170 14.5.21. 14:16


Computer Science Glossary
Adjacent (page 101): the item next to another item Combination (page 142): a joining of different parts
or qualities
Algorithm (page 94): a set of rules or instructions for
solving a problem Comparisons (page 101): checking one item against
another and looking for differences or similarities
Alphanumeric (page 76 ): text on page simply reads
‘letters and numbers’ Complex (page 150): more difficult / more
components involved
Ambient (page 49): the immediate Surroundings
Comprise (page 96): include, be made up of
Amplitude (page 14): the strength of a sound wave,
measured at the highest level Components (page 85): pieces of equipment in a
system
Analogue (page 14): using signals or information
represented by a continuously variable physical Compromise (page 74): become vulnerable or
quantity function less effectively

Analogue signals (page 44): continuous signals that Condition (page 145): the state of something in
cannot be processed by a computer until they relation to its appearance, quality or working order

are converted into digital data. Conductive (page 43): heat and electricity can pass
through an object
Array (page 45): a data structure that holds related
data. Control bus (page 37): a bus that carries instructions
from the CPU to control the actions of the computer
Architecture (page 34): how a computer system is
designed, including the rules and methods that the Computational thinking (page 95): breaking down a
system should follow problem into smaller sub-problems to solve them

Arithmetic (page 142): use of numbers to calculate Corruption (page 27): where something is altered or
an outcome changed without a user knowing

Automated (page 84): machines carrying out a job Constructs (page 114): the building blocks of
that would otherwise have been done by humans programming

Bandwidth (page 18): the transmission capacity of a Criteria (page 129): conditions or questions
computer network
Data duplication (page 130): a process of creating an
Barcode (page 28): a machine readable code in exact copy of data
the form of numbers and a pattern of parallel lines
of varying widths, printed on a physical item. This Data redundancy (page 130): the storing of the
pattern identifies it from other barcodes same data in multiple locations

Binary (page 2): a number system that contains just Data validation rules (page 133): these are some
2 numbers, 0 and 1, and the number system that a rules which help the user to know that the data
computer uses to process data being entered in a database is correct

Bluetooth (page 40): a form of wireless connection Debugging (page 64): finding errors or mistakes in
for connecting devices together when they are code

near each other Decipher (page 30): converting code into normal
language
Boolean (page 107): where a variable can have one
of two values, true or false Degrades (page 53): breaks down or deteriorates

Brainstorming (page 94]: an exhaustive discussion to Detects (page 152): identifies


solve problems or generate ideas
Dictation (page 44): the process of reading words
Capacitor (page 52): a small electronics device that into a microphone so that they can be converted
stores an electrical charge from analogue signals to digital words on a screen

Computer Science Glossary 171

SB CS PP.indb 171 14.5.21. 14:16


Division by zero (Page 62): a mathematical Interface (page 47): a device or program used to
calculation that has no answer, and one that is communicate with a computer
automatically rejected by a computer for this reason
Internet Protocol (IP)
Efficiently (page 2): to perform something in a well-
organised and competent way Address (Page 22): a unique string of numbers
separated by full stops that identifies each computer
Electrodes (page 43): a conductor where electricity using the protocol to communicate over a network
enters or leaves an object
Intervention (page 61): an action taken by someone
Electromagnetic (page 51): the electrical and to make something different happen
magnetic forces or effects produced by an electric
current. Intricate (page 34): very complicated or detailed

Entity (page 129): object or thing Inverted (page 12): reversed or transformed into its
corresponding opposite
Equivalent (page 142): the same or equal meaning
ISBN number (page 28): International Standard Book
Executable (page 63): a file that launches and runs a Number, a global system for identifying individual
series of code when opened books. ISBN numbers have 13 digits

Firmware (page 60): small applications which enable Hertz (page 15): frequency of samples, measured in
a computer to start all of its devices cycles per second

Floating-point (page 112): a number in Interrupt service routine (page 61): a software
programming that contains a decimal point, and the routine that hardware invokes in response to an
decimal point can ‘float’ in different places to help interrupt
with handling large numbers
jpeg (page 18): Joint Photographic Experts Group:
Foreign key (page 130): A foreign key is a fi eld or the organisation that created the file type
combination of fi elds that are related to the primary
key of another table Lightning connection (page 52): a high-speed
connection that was developed by Apple for the
Formally (page 143): officially / explicitly purpose of connecting multiple external devices to
their computers
Function (page 120): a block of organised, reusable
code used to perform a single, related action Logic gates (page 142): the basic units of a digit
circuit that control the flow of electronic signals
HDMI (page 45): high-definition multimedia
interface technology displays high-definition Logical reasoning (page 89): a set of reasonable
images and sound through a single cable. HDMI is a conclusions and explanations
standard connection port for audio/visual devices in
computers Microprocessor (page 49): Microprocessors are
integrated circuits that contains all the functions of
Hexadecimal (Page 55): a number system that uses a CPU of a computer
16 characters instead of the 10 characters used in
the decimal system or the two used in binary mp3 (page 18): MPEG (Moving Picture Experts
Group: the organisation that created the file type)
Hypertext transfer protocol (page 69): the agreed set Layer 3
of rules that all computers use for transmitting files
(data) over the world wide web Negotiations (page 94): a discussion to produce a
settlement or agreement
Impaired (page 15): weakened or damaged
Nibble (page 5): a set of four binary bits
Increment (page 117): to increase by a set number
Originator (page 22): the sending Device
Inefficient (page 113): not the best or fastest way of
achieving a goal Operating system (page 41): a piece of software that
communicates with the hardware and allows other
Infinitely (page 85): continues forever, until stopped programs to run

172 Computer Science Glossary

SB CS PP.indb 172 14.5.21. 14:16


Overflow (page 9): the generation of a number or Shift (page 9): movement either to the left or right
other data item that is too large for the assigned
location or memory space Simulate (page 64): run a test version of an
application
Parity (page 23): ensuring that something is the
same Simultaneously (page 25): at the same time

Parity check (page 27): is a bit added to a string of Sophisticated (page 75): more complex
binary code as the simplest form of error detecting
Sound card (page 48): an internal device of a
code
computer that provides a method of input and
Perspective (page 94): a particular way of thinking output of audio signals for use with multimedia
about something applications

Pictorially (page 100): in the form of a Diagram Spoof (page 74): something that is fake but pretends
to be genuine
Pixel (page 15): a tiny area of illumination on a
display screen String (page 129): a set of characters that can also
contain spaces and numbers
Platter (page 51): a circular magnetic plate that is
used for storing data in a hard disk. Stylus (page 41]: a pen that can be used either
directly onto a screen or a pad connected to a
Portability (page 53): the ability to carry or move computer
something
Substitute (page 76): exchange for something
Powers (page 2): the product obtained when a different
number is multiplied by itself a certain number of
times Syntax (page 64): the structure of not just
statements but also symbols, punctuation, etc., in a
Pressure (page 49): continuous physical force computing language
exerted on an object
Test strategy (page 96): test plans for testing the
Primary key (page 130): A primary key is a unique system
field that allows the user to identify a record
Transaction (page 29): the process of buying or
Protocol (page 27): a set of rules that are applied to selling something
the transfer of data
Translated (page 63): changed into a different
Pseudocode (page 98): a version of programmable language
code written in standard English
Transistor (page 3): a small electronics device that
Quarantine (page 75): to place into isolation carries, switches and amplifies an electrical current

Referred: (page 143) denoted / identified Truth tables (page 144): used to represent the
Boolean expression of a logic gate or logic circuit
Remainder (page 3): the number left over in a
division in which one quantity does not exactly Ubiquitous (page 26): located everywhere
divide another
Universal serial bus (USB) (page 40): a standard
Replicating (page 90): creating as close to a copy of connector found on many different types of
something as possible computer and used to connect external devices

Search engine (page 70): a web-based tool that is Utility (page 60): a small piece of software that
used to find web pages based on a given topic or controls specific parts of the hardware
keyword entered by the user. It then returns a list of
relevant web pages and their respective URLs Validation (page 104): the process that helps the
system know the data entered is correct
Serial advanced technology attachment (SATA)
( page 51): a type of cable usually found inside Validation check (page 104): testing for validations
computers. It connects a hard drive with the
motherboard

Computer Science Glossary 173

SB CS PP.indb 173 14.5.21. 14:16


Video conference (page 43): a form of visual Visualise (page 95): to be able to see a prototype of
communication where users in different places can an idea
see, hear and speak to each other using a variety of
equipment, including web cameras, monitors and Volatile (page 50): loses its contents when there is
microphones no electrical charge

174 Computer Science Glossary

SB CS PP.indb 174 14.5.21. 14:16


SB CS PP.indb 175 14.5.21. 14:16
SB CS PP.indb 176 14.5.21. 14:16
Cambridge IGCSETM
For over 60 years Marshall Cavendish Education has been
empowering educators and students in over 80 countries with
high-quality, research-based, Pre-K-12 educational solutions.

Cambridge
We nurture world-ready global citizens by equipping students
with crucial 21st century skills through our resources for schools
and education centres worldwide, including Cambridge schools,

Computer Science
IGCSE
catering to national and international curricula.

The Marshall Cavendish Education Cambridge IGCSETM Computer Science series


TM
is designed for students studying for the Cambridge IGCSE and IGCSE (9–1)

Computer Science
Computer Science syllabuses (0478/0984). The series focuses on developing
important computer science skills relevant to real-world applications.

SB The Student’s Book:


• Encourages active and inquiry-based learning through hands on activities and discussions
• Supports subject literacy with concise language, language support and bite-sized concepts
• Caters to the international landscape with multicultural photographs, visuals and other references
• Promotes visual learning through concept infographics and clear illustrations
• Includes mind maps and links that build learners’ understanding of the relationships between concepts
• Nurtures life-long learning in building digital literacy skills which students can use beyond their course
• Helps students develop 21st century competencies, so that they become future-ready

STUDENT’S

STUDENT'S BOOK
BOOK
This resource is endorsed by Series architecture
Cambridge Assessment International Education • Student’s Book
✓ Supports the full Cambridge IGCSE and IGCSE • Workbook
(9–1) Computer Science syllabuses (0478/0984) for • Teacher’s Guide
examination from 2023.
• e-book
✓ Has passed Cambridge International’s rigorous
quality-assurance process

✓ Developed by subject experts


✓ For Cambridge schools worldwide Greg Shilton
Megha Goel
ISBN 978-981-4941-59-4

9 789814 941594

C01(S)IGCSECS_SB_Cover.indd All Pages 12/5/21 11:11 AM

You might also like