76% found this document useful (34 votes)
190K views132 pages

Answers Key IGCSE Computer Science 2nd Edition Hodder CourseBook by David Watson

This document provides answers to exam-style questions and activities from the Cambridge IGCSE and O Level Computer Science Student's Book. It includes answers related to data representation, binary, hexadecimal, ASCII, sound file formats, image file sizes and compression techniques.

Uploaded by

alfaazmcs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
76% found this document useful (34 votes)
190K views132 pages

Answers Key IGCSE Computer Science 2nd Edition Hodder CourseBook by David Watson

This document provides answers to exam-style questions and activities from the Cambridge IGCSE and O Level Computer Science Student's Book. It includes answers related to data representation, binary, hexadecimal, ASCII, sound file formats, image file sizes and compression techniques.

Uploaded by

alfaazmcs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 132

Cambridge IGCSE™ and O Level Computer Science

Answers to Student’s Book


Exam-style questions and sample answers have been written by the authors. References to
assessment and/or assessment preparation are the publisher’s interpretation of the syllabus
requirements and may not fully reflect the approach of Cambridge Assessment International
Education. Cambridge International recommends that teachers consider using a range of teaching
and learning resources in preparing learners for assessment, based on their own professional
judgement of their students’ needs.
Cambridge Assessment International Education bears no responsibility for the example answers to
questions taken from its past question papers which are contained in this publication.
The questions, example answers, marks awarded and/or comments that appear in this digital
material were written by the author(s). In examination, the way marks would be awarded to
answers like these may be different.

1 Data representation
Answers to activities
1.1
a 51
b 127
c 153
d 116
e 255
f 15
g 143
h 179
i 112
j 238
k 487
l 1364
m 3855
n 1992
o 2047
p 31984
q 16141
r 49983
s 34952
t 32767

Cambridge IGCSE and O Level Computer Science Teacher's Guide 1


© David Watson and Helen Williams 2021
Answers to Student’s Book

1.2
a 00101001
b 01000011
c 01010110
d 01100100
e 01101111
f 01111111
g 10010000
h 10111101
i 11001000
j 11111111
k 1000000011101000
l 0000001101111000
m 0000111111111111
n 0100000000010000
o 1111001101100011
1.3
a C3
b F7
c 27F
d 4EE
e 1E1
f 89E
g (0)4FE
h (0)E9C
i FF7D
j 67AE
1.4
a 0110 1100
b 0101 1001
c 1010 1010
d 1010 0000 0000
e 0100 0000 1110
f 1011 1010 0110
g 1001 1100 1100
h 0100 0000 1010 1010
i 1101 1010 0100 0111
j 0001 1010 1011 0000

Cambridge IGCSE and O Level Computer Science Teacher's Guide 2


© David Watson and Helen Williams 2021
Answers to Student’s Book

1.5
a 107
b 156
c 74
d 255
e 511
f 2561
g 2996
h 3240
i 4782
j 44425
1.6
a 62
b E3
c 1EA
d 1FF
e 33A
f 3E8
g A4A
h E9F
i FA7
j 1388
1.7
1 Student investigation
2 a 35, 37, 8B
b C9, 7A, CC
c C, 6F, 51
1.8
a 10000011
b 01100110
c 01111011
d 10110110
e 01101111
f 10110111
g 01111110
h 01110000
i 11111110
j 11011101

Cambridge IGCSE and O Level Computer Science Teacher's Guide 3


© David Watson and Helen Williams 2021
Answers to Student’s Book

1.9
a 98 = 01100010 and 15 = 00001111; sum = 01110001 (= 113)
b 29 = 00011101 and 88 = 01011000; sum = 01110101 (= 117)
c 49 = 00110001 and 100 = 01100100; sum = 10010101 (= 149)
d 51 = 00110011 and 171 = 10101011; sum = 11011110 (= 222)
e 82 = 01010010 and 69 = 01000101; sum = 10010111 (= 151)
f 100 = 01100100 and 140 = 10001100; sum = 11110000 (= 240)
g 19 = 00010011 and 139 = 10001011; sum = 10011110 (= 158)
h 203 = 11001011 and 30 = 00011110; sum = 11101001 (= 233)
i 66 = 01000010 and 166 = 10100110; sum = 11101000 (= 232)
j 211 = 11010011 and 35 = 00100011; sum = 11110110 (= 246)
1.10
1 a 89 = 01011001 and 175 = 10101111; sum = 1 00001000 (= 8)
overflow error has occurred (9 bits)
b 168 = 10101000 and 99 = 01100011; sum = 1 00001011 (= 11)
overflow error has occurred (9 bits)
c 88 = 01011000 and 215 = 11010111; sum = 1 00101111 (= 47)
overflow error has occurred (9 bits)
2 a 1101 1111 0010 1010 – result is correct
b 1 1110 1011 1110 0100 – overflow error has occurred
1.11
1 a denary value = 64 + 32 + 8 = 104
0 0 0 0 1 1 0 1
b denary value is 13 (104 ÷ 8) therefore shift three places right is the same as division
by 23 (i.e. 8)
c denary value = 15
1 1 1 1 0 0 0 0
d denary value is 240 (15 × 16) therefore shift four places left is the same as multiplication
by 24 (i.e. 16)
2 a 29 = 00011101 and 51 = 00110011
b sum = 01010000
c 00001010
d 75 = 01001011
e 01010101
f 10101010

Cambridge IGCSE and O Level Computer Science Teacher's Guide 4


© David Watson and Helen Williams 2021
Answers to Student’s Book

1.12
1 a 00100111
b 01000010
c 01011000
d 01100110
e 01101111
f 01111101
g 01001101
h 00010100
i 00110001
j 00111000
2 a 85
b 51
c 76
d 126
e 15
f 125
g 65
h 30
i 113
j 120
1.13
a 11101110
b 11100001
c 11010001
d 11000001
e 10101000
f 10100100
g 10011100
h 11111111
i 11110000
j 10000001

Cambridge IGCSE and O Level Computer Science Teacher's Guide 5


© David Watson and Helen Williams 2021
Answers to Student’s Book

1.14
a −51
b −66
c −17
d −121
e −96
f −7
g −81
h −1
i −127
j −10
1.15
1 i The number of possible colours of a group of pixels (usually three or four) based on
the bit depth.
ii The coding system for all the characters on a standard keyboard and control codes;
extended ASCII, gives another 128 codes to allow for characters in non-English alphabets
and for some graphical characters to be included.
iii The coding system which represents all the languages of the world (the first 128 characters
are the same as ASCII code).
iv The number of sound samples taken per second.
v Images which are made up of pixels.
2 i, ii, iii each colour is 28 = 256
iv 256 × 256 × 256 = 16 777 216 possible colours
3 They both increase the size of the sound file.
1.16
1 1920 × 1536 = 2 949 120 pixels
colour depth = 16  16 × 2 949 120 = 47 185 920 bits
bits (÷ 8)  5 898 240 bytes
(÷ (1024 × 1024))  5.625 MiB
2 1024 × 1536 = 1 572 864 pixels
colour depth = 24  24 × 1 572 864 = 37 748 736 bits
bits (÷ 8)  4 718 592 bytes
16 GiB = 17 179 869 bytes
 number of photos = (17 179 869)/(4 718 592) = 3640 photos
3 a sample size = 44 100 × 8 × 2 (two tracks) = 705 600 bits
b file size = 44 100 × 8 × 30 × 2 (two tracks) = 21 168 000 bits
bytes (÷ 8)  2 646 000 bytes = 2.5 MiB

Cambridge IGCSE and O Level Computer Science Teacher's Guide 6


© David Watson and Helen Williams 2021
Answers to Student’s Book

4 sample size = 44 100 × 16 × 210 × 2 (two songs) = 296 352 000 bits
bytes (÷ 8)  37 044 000 bytes  35.33 MiB
 740 MiB CD can store 740/35.33 = 20.94  20 full songs
Answers to exam-style questions
Answers to questions 6 and 7 in this section are example answers for past paper questions. The details of
the relevant past paper can be found with the corresponding exam-style question in the Student’s Book.
1 a i The number of bits used to represent sound amplitude.
ii Better sound quality
Less sound distortion
b i The number of pixels that make up an image; for example, an image could contain
4096 × 3192 pixels (i.e. 12 738 656 pixels in total).
ii 4 bits 16 colours
iii 16 384 × 512 = 8 388 608 pixels
Colour depth = 256 (8 bits per pixel)
 8 388 608 × 8 = 67 108 864 bits
 (67 108 864/(1024 × 1024 × 1024)) = 0.0625 GiB
iv The developer may wish to use lossy compression and use the JPEG format to save
space on their camera and/or computer.
2 a The editor decides how many bits to represent the sound amplitude. Increasing the number
of bits to represent sound amplitude increases accuracy; this is sampling resolution.
The editor also decides how many samples per second should be taken; this is the sampling
rate – the higher the number of sound samples per second, the better the quality of the
sound recording.
b The editor will use lossy format, for example, MP3 format, which uses perceptual music
shaping, which removes sounds the ear cannot hear properly, therefore the sound quality is
essentially retained.
Lossless files would be larger than lossy files for little improvement in sound quality.
c i RLE is a form of lossless compression. It reduces the size of a string of adjacent,
identical data, for example, repeated colours of an image. The repeating string is
encoded into two values; one value represents the number of identical items and the
second value represents the code of the data item (ASCII code).
ii 3G 2W 4G 9W 4G 2W 1G 2W 2G 2W 1G (W = 1 and G = 0)
 30 21 40 91 40 21 10 21 20 21 10
8 × 4 grid = 32 bytes
RLE code = 11 × 2 = 22 bytes
 RLE saves 10 bytes of memory/storage

Cambridge IGCSE and O Level Computer Science Teacher's Guide 7


© David Watson and Helen Williams 2021
Answers to Student’s Book

3 a 32 + 16 + 4 + 2 = 54 (base 10)
b i 00011011
ii 16 + 8 + 2 + 1 = 27 (base 10)
c i 11011000
ii 128 + 64 + 16 + 8 = 216 (base 10)
Therefore two places shift to the left = multiply by 4 (22)
4 a Parts i to iii
0 1 1 1 1 0 1 1
0 0 1 1 0 1 1 1
1 0 1 1 0 1 0 0
b i 123 + 55 = 0 1 1 1 1 0 1 1 + 0 0 1 1 0 1 1 1 = 1 0 1 1 0 0 1 0 (178)
ii 123 + 180 = 0 1 1 1 1 0 1 1 + 1 0 1 1 0 1 0 0 = 1 0 0 1 0 1 1 1 1 (47), which is
incorrect; overflow has occurred
c i 01110100
two’s complement gives: 1 0 0 0 1 1 0 0 (−116)
ii −112 = 1 0 0 1 0 0 0 0
iii 1 0 1 1 1 0 0 1 = −128 + (32 + 16 + 8 +1) = −128 + 57 = −71
d i 01101000
ii 10011000
5 a A picture element is the smallest element used to make up an image; each pixel is
represented by a minimum of 8 bits and 3 pixels are needed to make up the RGB colours.
b The number of possible colours of a group of pixels (usually three or four) based on the
bit depth.
c 1140 × 1080 = 1 231 200 pixels
 1 231 200 × 24 = 29 548 800 bits
 (29 548 800)/8 = 3 693 600 bytes
Memory card is 32 × (1024 × 1024 × 1024) bytes
 number of photos = (32 × 1024 × 1024 × 1024)/(3 693 600) = 9302 photos
d Use file compression (e.g. JPEG) which reduces the size of the files/images being stored.
Therefore more files/images can be stored on a memory stick.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 8


© David Watson and Helen Williams 2021
Answers to Student’s Book

6 a • image converted from analogue to digital


• image turned into pixels
• each pixel is given a binary value
• pixels form a grid/pattern
• each pixel has associated colour
• pixels are stored in sequence
• meta data stored (dimensions, colour depth, etc.)
• for example, JPEG, raw, TIFF, PSD, PNG
b Lossy:
• lossy would reduce file size more than lossless
• unnecessary data removed from the file
• images can be of similar quality/won’t notice any difference
• no requirement for files to be the same as the original
• can send photos faster/faster to upload

7 a Hours 0 0 0 0 0 0 1 0
Minutes 0 0 0 1 1 1 1 1
Seconds 0 0 1 1 1 0 1 0

b 00000101=5
0 0 0 1 1 0 1 0 = 26
0 0 1 1 0 1 1 1 = 55
Time shown as:

8 a 64 GiB = 64 × 1024 × 1024 KiB


 (64 × 1024 × 1024)/10 = 6 710 886 photos
b i Use JPEG lossy file compression
ii • saves storage space
• faster to send photos by email
• quicker to download/upload photos
iii loss of quality
c i Each primary colour intensity needs to be stored as a byte to allow for sufficient
different colour variations.
ii 28 × 28 × 28 = 256 × 256 × 256 = 16 777 216

Cambridge IGCSE and O Level Computer Science Teacher's Guide 9


© David Watson and Helen Williams 2021
Answers to Student’s Book

Cambridge IGCSE and O Level Computer Science Teacher's Guide 10


© David Watson and Helen Williams 2021
Cambridge IGCSE™ and O Level Computer Science

Answers to Student’s Book


Exam-style questions and sample answers have been written by the authors. References to
assessment and/or assessment preparation are the publisher’s interpretation of the syllabus
requirements and may not fully reflect the approach of Cambridge Assessment International
Education. Cambridge International recommends that teachers consider using a range of teaching
and learning resources in preparing learners for assessment, based on their own professional
judgement of their students’ needs.
Cambridge Assessment International Education bears no responsibility for the example answers to
questions taken from its past question papers which are contained in this publication.
The questions, example answers, marks awarded and/or comments that appear in this digital
material were written by the author(s). In examination, the way marks would be awarded to
answers like these may be different.

2 Data transmission
Answers to activities
2.1
1 Parts i and ii
• picture and sound out of synchronisation
• packets arriving at different times
• pauses in the video
• time delay in assembling packets
• degraded video and sound
• caused by competing traffic on the communications link
• possible 'drop out'
• packets take different routes, so some may get lost
2 • web page divided into data packets
• each packet has an IP address of the destination
• routers check header against IP address values to determine next router to send data packet
• hop value checked to see if it is zero
• destination computer reassembles data packets to build up the web page
3 a This takes all the 1-values in the payload and adds them together to generate a hex number.
• this hex value is stored in the trailer
• receiving computer carries out the same calculation on received payload
• if values match, data packets has been received error-free
• if values do not match, data packet needs to be re-sent
b 29 1-bits  1D in hex. If recalculated value doesn’t equal 1Dhex then it needs to be re-sent.
4 a • packets keep 'bouncing around' from router to router and never reach the destination
• use hop numbers; if hop number = 0 then the packet is deleted and is therefore lost

Cambridge IGCSE and O Level Computer Science Teacher's Guide 1


© David Watson and Helen Williams 2021
Answers to Student’s Book

b • apply a hop number …


• … each time a data packet reaches a router, the hop number is decreased by 1
• … once the hop number = 0, and the destination hasn’t been reached, then the data
packet is deleted
c • each packet takes a different route …
• … therefore if a packet is intercepted, hacker still won’t have the whole message
2.2
1 i data sent one bit at a time over a single channel in both directions, but not at the same time
ii several bits of data sent down multiple channels in both directions, at the same time
iii data sent one bit at a time over a single channel in one direction only
2 i serial, simplex data transmission
ii parallel, simplex data transmission
iii parallel, full-duplex data transmission
iv serial, full-duplex data transmission
v parallel, simplex data transmission
2.3

Statement True False


Packets have a header which contains the IP address of the sender and

the receiver

Packets don’t require any form of error checking 

USBs use a protocol that allows for error-free data transmission



between device and computer

Serial data transmission suffers from data skewing 

The longest cable length supported by USB is 5 metres or less 

Simplex data transmission occurs when data is transmitted one bit at



a time

Full-duplex data transmission involves sending 8 bits of data at a time 

USB uses serial data transfer 

Packet switching prevents loss of any data packets 

USB connections can transfer data using half-duplex or full-duplex 

2.4
Parity bits: 1, 0, 1, 1, 0, 0, 1, 0, 1, 0
2.5
1 no error, error, error, no error, error, error, no error, no error, no error, no error

Cambridge IGCSE and O Level Computer Science Teacher's Guide 2


© David Watson and Helen Williams 2021
Answers to Student’s Book

2 It isn’t possible to determine where the error occurred.


2.6
1 error occurred in: byte 4 (four 1-bits)
and in: bit 6 (four 1-bits)
byte 4 should be: 0 1 1 0 1 1 1 0
2 error occurred in: byte 8 (three 1-bits)
and in: bit 7 (three 1-bits)
byte 8 should be: 0 1 0 1 0 0 1 1
2.7
1 9 + 8 + 5 + 0 + 5 + 5 = 32
3 × (7 + 1 + 1 + 4 + 7 + 9) = 3 × 29 = 87
(32 + 87)/10 = 119/10 = 11 remainder 9
10 – 9 = 1, the check digit
2 i ISBN 13: 2 + 3 + 1 + 0 + 0 + 2 = 8
3 × (1 + 1 + 1 + 0 + 4 + 8) = 3 × 15 = 45
(8 + 45)/10 = 53/10 = 5 remainder 3
10 – 3 = 7, the check digit
Modulo-11: sum = (13 × 2) + (12 × 1) + (11 × 3) + (10 × 1) + (9 × 1) + (8 × 1) + (7 × 0)
+ (6 × 0) + (5 × 0) + (4 × 4) + (3 × 2) + (2 × 8)
 26 + 12 + 33 + 10 + 9 + 8 + 0 + 0 + 0 + 16 + 6 + 16 = 136
136/11 = 12 remainder 4
11 – 4 = 7, the check digit
ii ISBN 13: 9 + 9 + 1 + 1 + 3 + 4 = 27
3 × (0 + 8 + 2 + 2 + 5 + 4) = 3 × 21 = 63
(27 + 63)/10 = 90/10 = 9 remainder 0
check digit = 0
Modulo-11: sum = (13 × 9) + (12 × 0) + (11 × 9) + (10 × 8) + (9 × 1) + (8 × 2) + (7 × 1)
+ (6 × 2) + (5 × 3) + (4 × 5) + (3 × 4) + (2 × 4)
 117 + 0 + 99 + 80 + 9 + 16 + 7 + 12 + 15 + 20 + 12 + 8 = 395
395/11 = 35 remainder 10
11 – 10 = 1, the check digit
2.8
1 Tom would need to send Jane his public key.
2 Two keys are required; one of the keys is only known to the recipient of the document
(i.e. the private key).

Cambridge IGCSE and O Level Computer Science Teacher's Guide 3


© David Watson and Helen Williams 2021
Answers to Student’s Book

2.9
a E – text following an encryption algorithm
b B – the receiver
c B – plaintext
d E – there is a security problem when transmitting the encryption key
e A – symmetric key encryption
f E – check digit
g A – automatic repeat request
h B – parity check
i D – checksum
j A – echo check

Answers to exam-style questions


Answers to questions 7 and 8 in this section are example answers for past paper questions. The details of
the relevant past paper can be found with the corresponding exam-style question in the Student’s Book.
1 a i Data is returned to sender. Sender’s computer compares the two sets of data. If any
errors found, then the data is re-sent.
This doesn’t make it a very suitable method for this application.
ii ARQ uses acknowledgement and timeout. When a receiving device detects an error
following data transmission, it asks for the data to be re-sent. If there are no errors, a
positive acknowledgement is sent to the sender.
The sending device will re-send data if:
• it receives a request to re-send data
• a timeout has occurred.
The whole process is continuous until all data packets received are error-free or until
the timeout is reached.
b Three differences from:
Checksum Check digit
• calculated from the block of data • final digit included in the code
• sent with block of data • calculated from the other digits in the code
• re-calculated at the receiving station • used to check for errors during data entry
• if different, an error has occurred • detects errors such as transposition,
• used to check errors following data missing/extra digits, and so on
transmission

Cambridge IGCSE and O Level Computer Science Teacher's Guide 4


© David Watson and Helen Williams 2021
Answers to Student’s Book

2 i Packet switching is a method of data transmission where a message is broken into many
data packets, which can then be sent along different pathways independently of each other.
ii Cyclic redundancy check is an error-checking method which adds up all the 1-bits in the
data packet payload and stores this hex number in the trailer; the same calculation is done
at the receiving station.
iii Data skewing occurs when data arrives at the destination with the bits no longer
synchronised; this usually occurs during parallel data transmission.
iv Universal serial bus is a type of serial data transmission which has become the industry
standard for connecting computers to devices using the USB port.
v Parity bit (0 or 1) is added to a byte of data in the most significant bit position (left-most
bit); this ensures that the byte follows the correct even parity or odd parity protocol.
3 Checksum Parity check ARQ
Description
  

Extra bit sent with each byte of data 

Makes use of timeout and acknowledgement 

If an error is found, a request is made to re-send



the data
Check on whether a data packet has been
 
changed following transmission
Re-calculation made on any additional data
 
values sent to the recipient

Data is transmitted in blocks or packets  () 

A method that can determine which bit in a



data stream has been changed
Additional value sent at the end of a block of
data to be used to check if any data 
transmission errors occurred

4 a Sequence: iii, i, ii, iv


b Sequence: v, ii, iii, iv, i
c Sequence: ii, iii, i, iv, v
d Sequence: vi, v, ii, iv, iii, i
5 a Symmetric encryption occurs when the same encryption key is used to encrypt and decrypt
a message.
b Asymmetric encryption uses public keys (known to everyone) and private keys (known to
a single user only); the recipient sends a public key to each sender who uses it to encrypt
the message. The encrypted message is then decrypted using a matching private key at the
recipient’s computer.
c If data is intercepted it cannot be understood by a hacker/eavesdropper without the correct
decryption key.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 5


© David Watson and Helen Williams 2021
Answers to Student’s Book

Cambridge IGCSE and O Level Computer Science Teacher's Guide 6


© David Watson and Helen Williams 2021
Answers to Student’s Book

7 a i
Method 1 Tick  Method 2 Tick 

Serial  Simplex

Parallel Half-duplex

Full-duplex 

ii Serial has lower/less interference.


Serial is more reliable over long distances.
In serial, bits won’t be skewed/out of synchronisation.
In serial, it is easier to collate bits together again after transmission.
Full-duplex transmits data in both directions at the same time.
Simplex and half-duplex won’t allow read and write operations at the same time.
b Any two from:
Checksum:
• value calculated from the data block
• this value is transmitted along with the data
• checksum recalculated after transmission
• if the values match, data has been transmitted error-free
Parity check:
• parity bit is transmitted with each byte of data
• odd or even parity protocol is being used
• number of 1-bits are added together to determine if parity bit is 0 or 1
• byte checked at destination to see if it has the correct parity protocol (odd or even)
• if the parity has changed, an error has occurred
ARQ:
• uses acknowledgement and timeout
• when device detects an error in the data transmission, it requests the packet to be
re-sent; if no error, a positive acknowledgement is sent
• sending device re-sends packet after request to re-send is made/timeout reached
• process is continuous until the data packet received is correct/until ARQ time limit
is reached
Echo check:
• copy of data sent back to sender
• data is compared to see if they match
• if it does not match, error has been detected

Cambridge IGCSE and O Level Computer Science Teacher's Guide 7


© David Watson and Helen Williams 2021
Answers to Student’s Book

8 a True False
Statement
 

Full-duplex data transmission can be either serial or parallel 

Full-duplex data transmission is when data is transmitted both ways,



but only one way at a time
Full-duplex transmission is always used to connect a device to

a computer
Full-duplex data transmission is when data is transmitted both ways

at the same time

Full-duplex data transmission automatically detects any errors in data 

b parallel data transmission


c Two from:
• universal standard, so it is likely to be compatible with the computer
• can only be inserted one way, so there is less chance of connecting a device incorrectly
• high-speed data connection, so data transmission is fast
• uses serial transmission, so less chance of skewing errors
• does not require (wireless) network, therefore can be used even if network is down
• backwards compatible, so no additional technology required
• no need for a separate power source, because USB supplies (5V) power
• drivers are automatically identified/loaded, so no need to find them online/installs
drivers automatically

Cambridge IGCSE and O Level Computer Science Teacher's Guide 8


© David Watson and Helen Williams 2021
Cambridge IGCSE™ and O Level Computer Science

Answers to Student’s Book


Exam-style questions and sample answers have been written by the authors. References to
assessment and/or assessment preparation are the publisher’s interpretation of the syllabus
requirements and may not fully reflect the approach of Cambridge Assessment International
Education. Cambridge International recommends that teachers consider using a range of teaching
and learning resources in preparing learners for assessment, based on their own professional
judgement of their students’ needs.
Cambridge Assessment International Education bears no responsibility for the example answers to
questions taken from its past question papers which are contained in this publication.
The questions, example answers, marks awarded and/or comments that appear in this digital
material were written by the author(s). In examination, the way marks would be awarded to
answers like these may be different.

3 Hardware
Answers to activities
3.1
1 a address bus, data bus, control bus
b address bus: carries addresses throughout the computer; it is unidirectional
data bus: bidirectional bus allowing data to be sent throughout the computer
control bus: carries signals from the control unit to all other computer components;
it is bidirectional
c • wider address and data buses would increase computer performance
• wider control bus would have little, if any, effect on performance
• higher clock speed would increase processor speed, (overclocking could have serious
consequences however, such as unsynchronised operations or overheating)
2 fetches
current instruction register (CIR)
program counter (PC)
memory address register (MAR)
address bus
memory data register (MDR)
decoded
executed
control signals
control bus
arithmetic and logic unit (ALU)
accumulator (ACC)

Cambridge IGCSE and O Level Computer Science Teacher's Guide 1


© David Watson and Helen Williams 2021
Answers to Student’s Book

3.2
1 a • increasing the width of the address bus and width of the data bus
• increasing clock speed but care needed to avoid over-clocking
• use of larger cache memories (uses static RAM) which have faster data access time
than normal RAM (which is dynamic)
• using dual core and quad core processors; but doubling number of cores doesn’t double
processor performance since the CPU needs to communicate with each core which uses
up time
b • instructions are a set of operations which are decoded in sequence
• each operation is made up of an opcode (which informs the CPU about what operation
needs to be done) and an operand (data which needs to be acted on/register)
• limited number of opcodes exist and this is known as an instruction set
• instruction sets are low level language instructions which instruct the microprocessor
how to carry out an operation
2 a • destination address input
• other factors (e.g. avoiding toll roads) are input
• data from satellites, which gives the location of three or four satellites …
• … together with very accurate timings
• Sat Nav computer uses satellite data to calculate the position of a car on the
stored maps
• this combination allows accurate tracking of the vehicle on stored roads
b • use of satellite or cellular network used to download the latest map updates/software
updates
• if the Sat Nav is a portable unit, it can be connected to a computer via USB port and
new maps/software will be downloaded
3.3
1 a || wwwbwbb/wwwbbwb/wwwbbwb || bwwwwbw/bwbbbww/bbbwwbw ||
b || wwbbwwb/wwbwwbb/wbbwwwb/wbbbwbb ||
bwbwwww/bwbwwww/bwbbbww/bwwbwww ||
c || wwwbbwb/wbbwwwb/wbbwbbb/wbbwbbb/wwwbwbb ||
bbbwwbw/bbwbbww/bbbwbww/bbwwbbw/bwwbwww ||
2 a • hold more information
• fewer errors due to built-in error-checking in QR codes
• easier to read – QR codes can be read by a smartphone/tablet camera and app
• QR codes can be encrypted
b 40 × 40 = 1600 pixels = 1600 bits = 200 bytes
c • they are used as a form of alignment when reading the QR code
• the remaining corner square is used to ensure the correct size and correct angle of QR
camera shot
d • more than one QR format exists

Cambridge IGCSE and O Level Computer Science Teacher's Guide 2


© David Watson and Helen Williams 2021
Answers to Student’s Book

• QR codes can contain malicious codes (called attagging); QR code software is free;
therefore, it is easy to embed malicious software or fake websites
3.4
1 a Laser printer:
• uses dry powdered ink (toner)
• makes use of the properties of static electricity to produce text and images on paper
• prints whole page in one go
• ink is fused onto paper using heated rollers
Inkjet printer:
• uses liquid ink in four or five cartridges
• printing is done line by line as paper advances forward after each printed line
• ink droplets are ejected onto paper using thermal bubble or piezoelectric technology
b Parts i and ii
Laser printer:
• high-quality flyers and posters (in large quantities)
• any large volume printing job
• equipped with large capacity toner cartridges
• have large paper trays
Inkjet printer:
• one-off printouts, such as photos
• small batch printing jobs
• can print on various types of paper and other media (for example, can print on T-shirts)
• where small paper trays and small capacity ink cartridges are not important for small
print jobs
2 Order: C, E, G, A, I, B, F, H, D
3 a In an LCD–LED screen, each pixel is made from liquid crystals that are backlit using
LEDs. In pure LED screens, the pixels are made up of the LEDs themselves.
b LEDs:
• use less power
• they do not need to warm up to reach maximum brightness
• produce a 'whiter' light
• produce a brighter light
• last for much longer
4 • Filipe uses an application on his computer that can play music files.
• The application finds the files on the backing store (HDD or SSD) and moves it into RAM.
• The data in the file is read by the application and then sent via a device driver to
loudspeakers which are connected to the computer.
• The device driver software translates the digital data into a series of analogue electrical
signal using a digital-to-analogue converter (DAC).
• The electrical signals make the loudspeaker cones move, through the use of a solenoid.
• If the file is a stereo recording then two different signals are sent to each loudspeaker.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 3


© David Watson and Helen Williams 2021
Answers to Student’s Book

• The movement of the loudspeaker cone moves molecules of air, which Filipe's ears detect,
and means he can hear music.
3.5
1 a Control:
• sensors used to collect data to send to a microprocessor
• sensor data is compared to stored/pre-set data
• the output affects the next set of inputs
• microprocessor sends signals to actuators to operate valves, motors and switches
Monitoring:
• sensors used to collect data to send to a microprocessor
• sensor data is compared to stored/pre-set data
• no actual changes to the process are made
• results of data comparison are shown on a screen/printed out or an alarm is activated
b • temperature and humidity sensors are used
• both sensors constantly send data to a microprocessor
• the data is converted to digital, if necessary, using an ADC
• the temperature levels are set by the user …
• … humidity levels are set at the factory
• if the temperature sensor reading > set temperature, the microprocessor will send
a signal to an actuator …
• … to switch on the air conditioning unit
• if the temperature sensor reading <= the set temperature, the microprocessor will send
a signal to an actuator …
• … to switch off the air conditioning unit
• if the humidity sensor reading > factory set value, the microprocessor will send a signal
to an actuator …
• … to switch on the air conditioning unit
• if the humidity sensor reading <= the factory setting AND temperature sensor reading
< the set temperature …
• … the microprocessor will send a signal to an actuator to switch off the air
conditioning unit
• the process is continuous
2 • pH sensors send data back to microprocessor
• data changed to digital if necessary (using ADC)
• if pH < stored value then microprocessor sends signals to actuators …
• … to open valve to add alkaline solution to soil
• if pH > stored value then microprocessor sends signals to actuators …
• … to open valve to add acidic solution to soil
• if pH = stored value then microprocessor sends signals to actuators …

Cambridge IGCSE and O Level Computer Science Teacher's Guide 4


© David Watson and Helen Williams 2021
Answers to Student’s Book

• … to close all valves


• the process is continuous
3 • readings taken from pressure and temperature sensors
• readings changed to digital if necessary (using ADC)
• readings are sent to microprocessor
• if temperature > stored value, microprocessor sends signal to actuators …
• … to open water valves
• if temperature <= stored value, microprocessor sends signals to actuators …
• … to close water valves
• if pressure >= stored value, microprocessor sends signals to actuators …
• … to close CO2 gas valves
• if pressure < stored value, microprocessor sends signals to actuators …
• … open CO2 gas valves
• monitoring/control is continuous
4 • pressure sensors in all four roads at junction used to detect vehicles approaching lights in
all directions
• data is sent back to a microprocessor
• number of vehicles approaching each set of traffic lights is calculated by the
microprocessor based on sensor data
• generated data is compared to a data model stored in the microprocessor system
• signals sent by the microprocessor to alter light sequences as required
• monitoring of roads is a continuous process
3.6
1 a RAM – settings (time, weight, defrost, …)
ROM – microwave wavelength, pre-programmed cooking times, safety systems
b RAM – temperature settings
ROM – control program to monitor fridge
c RAM – user settings, bespoke programs
ROM – wavelength of remote signals, pre-programmed flights, …
3.7
1 RAM:
• used by both OS and applications software
• when phone switched on, it pulls OS and app data from solid state memory to allow it to
function; user’s data
Solid state:
• used to store apps and operating system so that it is always there even when phone
switched off
• part of solid-state memory not accessible to users (for example, the OS)
• stores user’s photos, music files, and so on
2 a • uses movement of data between RAM and HDD/SSD

Cambridge IGCSE and O Level Computer Science Teacher's Guide 5


© David Watson and Helen Williams 2021
Answers to Student’s Book

• RAM is physical memory and virtual memory is RAM + swap space on HDD/SSD
• to execute a program, data is loaded into RAM from HDD/SSD
• gives the illusion that RAM is much larger than it really is
b • when P5 wants access to RAM we use virtual memory since RAM is full
• assuming P1 is oldest data, P1 data (10 GiB) is moved out of RAM into HDD/SSD
• P5 now points to memory space in RAM once occupied by P1
• process continues to allow all five programs to run in RAM
3

4 a RAM: ROM:
• temporary memory device • permanent memory device
• volatile memory • non-volatile memory device
• can be written to and read from • read-only
• used to store data, files, programs, • used to store the boot-up instructions
part of OS currently in use • an increase in the amount of ROM has no
• can be increased in size to improve effect on computer performance
operational speed of a computer
• a computer has far more RAM
memory than ROM memory
b For example:
• RAM – used by a PC to store the contents of an application when the computer
is running
• ROM – used by a PC to find out what it should to do when the power is switched on

Cambridge IGCSE and O Level Computer Science Teacher's Guide 6


© David Watson and Helen Williams 2021
Answers to Student’s Book

5 a electrons
NAND
matrix
intersection
control gate
floating gate
electrons
control gate
b Compared to HDDs, SSDs:
• have faster data access times
• are lighter
• consume less power
• don’t get as hot
• are thinner
• are more reliable
c More expensive – questions over how long they can store data for
3.8
1 a • A network interface card (NIC) is needed to allow a device to connect to a network
(such as the internet).
• It is usually part of the device hardware and contains the Media Access Control (MAC)
address generated at the manufacturing stage.
b • Media Access Control is an address which refers to a number which uniquely identifies
a device on the internet.
• It takes the form: NN-NN-NN-DD-DD-DD.
c • Internet Protocol identified either as IPv4 or IPv6
• It gives a unique address to each device connected to the internet which identifies
their location.
d • These enable data packets to be routed between the different networks, for example, to
join a LAN to a WAN onto the internet.
e • A server that automatically provides and assigns an IP address.
2 a • changes each time a device connects to the internet
• allows for greater privacy
• can be less reliable for some applications (e.g. VoIP)
b • IP address is associated with a particular device and does not change each time the
device connects to the internet
• allows faster upload and download speeds
• less privacy as a specific device can be identified by its IP address
c Dynamic IP addresses are needed for the following reasons:
• they give greater privacy since they change each time a user logs on

Cambridge IGCSE and O Level Computer Science Teacher's Guide 7


© David Watson and Helen Williams 2021
Answers to Student’s Book

• dynamic IP addresses can be an issue when using, for example, VoIP since this type of
addressing is less reliable as it can disconnect and change the IP address causing the
VoIP connection to fail
Static IP addresses are needed for the following reasons:
• since static IP addresses don’t change, they allow each device to be fully traceable
• allow for faster upload and download speeds
3 MAC:
• Permanent address associated with the piece of hardware
• Unique
• 48-bit address
• Used to find the particular device within a network
IP:
• An address assigned to hardware by an ISP – even a static IP address is not physically
associated with the hardware
• Not necessarily unique
• 32 (IPv4) or 128 (IPv6) bit address
• Used to route data to the correct network
Answers to exam-style questions
Answers to questions 7–9 in this section are example answers for past paper questions. The details of
the relevant past paper can be found with the corresponding exam-style question in the Student’s Book.
1 a • The plastic, organic layers of an OLED are thinner, lighter and more flexible than the
crystal structures used in LEDs or LCDs.
• The light-emitting layers of an OLED are lighter; OLED layers can be made from
plastic rather than the glass used in LED and LCD screens.
• OLEDs give a brighter light than LEDs.
• OLEDs do not require backlighting like LCD screens – OLEDs generate their
own light.
• Since OLEDs require no backlighting, they use much less power than LCD screens
(most of the LCD power is used to do the backlighting); this is very important in
battery-operated devices such as mobile phones.
• Since OLEDs are essentially plastics, they can be made into large, thin sheets (this
means they could be used on large advertising boards in airports, subways, and so on).
• OLEDs have a very large field of view, about 170 degrees, which makes them ideal for
use in televisions and for advertising screens.
b • many colours are possible if each primary colour (RGB) uses several bits to represent
its colour intensity …
• … for example, 32 bits per colour gives 232 × 232 × 232 possible colour combinations
• however, the human eye cannot detect more than a few thousand different colour
shades …
• … therefore, it is impossible to experience the 1 million different colours as claimed by
the manufacturer

Cambridge IGCSE and O Level Computer Science Teacher's Guide 8


© David Watson and Helen Williams 2021
Answers to Student’s Book

• television contrast (etc.) needs to be set up perfectly to show all colours accurately
2 a i Two from:
• cannot be changed by the user
• more difficult to copy the software
• immediately available as soon as device powered up
• programs are permanently stored
ii RAM allows the user to store their own data, such as game status
• only the part of the software needed at each stage in the game would be in RAM at
any time
iii USB ports allow other games stored on memory sticks, for example, to be plugged into
the games console
• can plug the console into external speakers for better sound effects
• can plug in keyboard and/or mouse to navigate menu systems
• can plug in VR headsets for consoles with this capability
b • the design may change several times …
• … therefore, it is cheaper and quicker to make a prototype using a 3D printer
• the 3D solid object lets the development team see how well it will work in real life
before building the final version
3 a • both use sensors to gather data
• in control, the output affects the input and actuators are used to change the process
(for example, open valve, operate pump)
• in monitoring, no changes to the process are made; the system simply shows the status
on a screen or prints out data or sounds an alarm
b • temperature and humidity sensors are used
• both sensors constantly send data to a microprocessor
• the data is converted to digital, if necessary, using an ADC
• the temperature levels are set by the user …
• … humidity levels are set at the factory
• if the temperature sensor reading is > set temperature, the microprocessor will send a
signal to an actuator …
• … to switch on the air conditioning unit
• if the temperature sensor reading <= the set temperature, the microprocessor will send
a signal to an actuator …
• ... to switch off the air conditioning unit
• if the humidity sensor reading > factory set value, the microprocessor will send a signal
to an actuator …
• … to switch on the air conditioning unit
• if the humidity sensor reading <= factory setting AND temperature sensor reading < set
temperature …
• … the microprocessor will send a signal to an actuator to switch off the air
conditioning unit

Cambridge IGCSE and O Level Computer Science Teacher's Guide 9


© David Watson and Helen Williams 2021
Answers to Student’s Book

• the process is continuous


4 a • static IP address doesn’t change
• dynamic IP address is a temporary IP address assigned to a device each time it logs
onto the internet
• dynamic IP addresses make use of a Dynamic Host Configuration Protocol (DHCP)
server which assigns the IP addresses whereas static IP addresses are assigned by
the ISP
• static IP addresses assigned to servers which host websites or to FTP servers; this gives
the device a consistent location and also means less bandwidth is used reducing
network traffic (and takes less time to retrieve data)
• dynamic IP addresses afford greater privacy since they change each time a device logs
onto the internet, therefore it makes the device more difficult to trace
b • MAC address is a media access control address
• MAC is used to uniquely identify a device
• uses the format: NN – NN – NN – DD – DD – DD
• where NN – NN – NN refers to the manufacturer and DD – DD – DD refers to the
serial number of the device
• there are two types referred to as UAA (set at factory) or LAA (can be changed
by user)
5 a

Cambridge IGCSE and O Level Computer Science Teacher's Guide 10


© David Watson and Helen Williams 2021
Answers to Student’s Book

b RAM: ROM:
• temporary memory device • permanent memory device
• volatile memory • non-volatile memory device
• can be written to and read from • data cannot be altered
• used to store data, files, part of OS • sometimes used to store the BIOS
currently in use and other start-up procedures
• can be increased in size to improve the
performance of computer
c DVD: Blu-ray:
• uses red laser technology • uses blue laser technology
• storage capacity is ~ 4.7 GB max • storage capacity can be up to ~ 50 GB
• doesn’t allow great interactivity • allows much greater interactivity
• relatively easy to copy • has built-in data encryption
• data transfer rate is ~ 10 Mbps • data transfer rate is ~ 36 Mbps
• always comes in dual-layer format • can come in single-layer, dual-layer …
up to 6-layer formats
6 a Capacitive touch screens:
• capacitive touch screens are composed of a layer of glass (protective layer),
a transparent electrode (conductive) layer and a glass substrate
• since human skin is a conductor of electricity, when bare fingers (or special stylus)
touch the screen, the electrostatic field of the conductive layer is changed
• the installed microcontroller is able to calculate where this change took place and
hence determine the coordinates of the point of touching

• with surface capacitive screens, sensors are placed at the corners of a screen
• small voltages are also applied at the corners of the screen creating an electric field
• a finger touching the screen surface will draw current from each corner reducing
the capacitance
• a microcontroller measures the decrease in capacitance and hence determines the point
where the finger touched the screen
• this system only works with a bare finger or stylus
• with projective capacitive screens, the transparent conductive layer is in the form of
an X–Y matrix pattern
• this creates a three dimensional (3D) electrostatic field
• when a finger touches the screen it disturbs the 3D electrostatic field allowing a
microcontroller to determine the coordinates of the point of contact
• this system works with bare fingers, stylus and thin surgical or cotton gloves; it also
allows multi-touch facility (for example, pinching or sliding)

Cambridge IGCSE and O Level Computer Science Teacher's Guide 11


© David Watson and Helen Williams 2021
Answers to Student’s Book

Infrared touch screens:


• infrared touch screens use a glass screen with an array of sensors and infrared
transmitters
• the sensors detect the infrared radiation; if any of the infrared beams are broken (for
example, with a finger touching the screen), the infrared radiation reaching the sensors
is reduced
• the sensor readings are sent to a microcontroller which calculates where the screen
was touched
Resistive touch screens:
• these screens are made up of two layers of electrically resistive material with a voltage
applied across them
• the upper layer is made of flexible polyethylene (a type of polymer) with a resistive
coating on one side
• the bottom layer is made of glass also with a resistive coating (usually indium tin
oxide) on one side
• these two layers are separated by air or an inert gas (such as argon)
• when the top polyethylene surface is touched, the two layers make contact
• since both layers are coated in a resistive material, a circuit is now completed which
results in a flow of electricity
• the point of contact is detected where there was a change in voltage
• a microcontroller converts the voltage (created when the two resistive layers touch) to
digital data which it then sends to the microprocessor
b i Uses organic layers which emit their own light and therefore there is no need for any
backlighting
ii • The plastic, organic layers of an OLED are thinner, lighter and more flexible than
the crystal structures used in LEDs or LCDs.
• The light-emitting layers of an OLED are lighter; OLED layers can be made from
plastic rather than the glass used in LED and LCD screens.
• OLEDs give a brighter light than LEDs.
• OLEDs do not require backlighting like LCD screens – OLEDs generate their
own light.
• Since OLEDs require no backlighting, they use much less power than LCD screens
(most of the LCD power is used to do the backlighting); this is very important in
battery-operated devices such as mobile phones.
• Since OLEDs are essentially plastics, they can be made into large, thin sheets
(this means they could be used on large advertising boards in airports, subways,
and so on).
• OLEDs have a very large field of view, about 170 degrees, which makes them
ideal for use in televisions and for advertising screens.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 12


© David Watson and Helen Williams 2021
Answers to Student’s Book

7 a touchscreen/concept keyboard/microphone/trackerball/touchpad
b headphones/speakers
c (removable) hard disk drive/SSD/USB drive/Blu-ray disk
d • QR code scanned using a camera on smartphone or tablet
• QR code is decoded/read using the app on the smartphone/tablet
• customer is provided with text about the animal
• customer is directed to a website about the animal
• QR code can be saved for future use
8 a input device which measures/takes readings from the surroundings/environment
b • moisture sensor:
• measures water content of the soil
• alerts Anna when soil is too dry/too wet
• maintains correct water level in the soil
• pH sensor:
• measures how acidic/alkaline the soil is
• alerts Anna when there may be something polluting the soil
• maintains correct pH level of the soil
• light sensor:
• measures brightness of the surroundings
• alerts Anna when fruit has too little/too much light
• temperature sensor:
• measures the temperature of the surroundings
• alerts Anna when it is too hot/too cold for optimum growing conditions
• gas/O2/CO2 sensor:
• measures amount of CO2 in the air
• alerts Anna if CO2 levels are too high/too low
• humidity sensor:
• measures the water content of the air
• alerts Anna if the air is too dry/too damp
• infrared sensor/motion sensor:
• measures infrared/microwaves
• detects intruders/wild animals
• pressure sensor:
• measures the weight of fruit fallen to the ground …
• … to alert Anna about how much fruit has fallen from the trees

Cambridge IGCSE and O Level Computer Science Teacher's Guide 13


© David Watson and Helen Williams 2021
Answers to Student’s Book

Cambridge IGCSE and O Level Computer Science Teacher's Guide 14


© David Watson and Helen Williams 2021
Cambridge IGCSE™ and O Level Computer Science

Answers to Student’s Book


Exam-style questions and sample answers have been written by the authors. References to
assessment and/or assessment preparation are the publisher’s interpretation of the syllabus
requirements and may not fully reflect the approach of Cambridge Assessment International
Education. Cambridge International recommends that teachers consider using a range of teaching
and learning resources in preparing learners for assessment, based on their own professional
judgement of their students’ needs.
Cambridge Assessment International Education bears no responsibility for the example answers to
questions taken from its past question papers which are contained in this publication.
The questions, example answers, marks awarded and/or comments that appear in this digital
material were written by the author(s). In examination, the way marks would be awarded to
answers like these may be different.

4 Software
Answers to activities
4.1
1 Software System software Application software

Screensaver 
Anti-virus software 
Control and measurement software 
Printer driver 
Video editing software 
Compiler 
QR code reader 
On-screen calculator 
Operating system software 

Cambridge IGCSE and O Level Computer Science Teacher's Guide 1


© David Watson and Helen Williams 2021
Answers to Student’s Book

2 a buffer
b • data sent to printer buffer
• meanwhile, data from download/video buffer is sending data to video player
• once printer buffer is full, attention returned to video download and video buffer starts
to fill again
• document starts to print
• when printer buffer is empty, an interrupt is sent to microprocessor requesting
more data
• microprocessor temporarily halts video download process to service printer
• more data is sent to the printer buffer
• meanwhile video player plays movie
• if video buffer is at minimum value, an interrupt is sent to stop other processes to allow
video buffer to start filling again
• process goes on until whole document is printed out
c interrupt sent to CPU indicating an error and message appears on screen; printing process
suspended until new black ink cartridge is installed
3 Human computer interface can be CLI or GUI; permits user to interact with computer
Multitasking allows computer to carry out several tasks at the same time
(allocating resources to each task)
Platform (to run software) all apps come under the control of OS; manages movement
of data into and out of RAM to allow software to run with
required resources
User account management allows more than one user to log onto a computer; each user
is allocated separate parts of memory; administrator has
overall control
Managing files carries out specific tasks (for example, create, open, close,
delete, rename, copy, etc.); maintains directory structures;
monitors access control mechanisms and ensures they are
maintained; loads files into memory as required
Hardware management involves management of all I/O devices; communicates
with devices via device drivers; ensures allocation of
resources according to priority; manages queues and buffers
Memory management manages RAM and keeps track of which apps are using
memory locations; prevents competing apps from using the
same memory locations
Interrupt handling handles interrupts from hardware and software to ensure
they are serviced in correct priority and that all devices
have access to the CPU and resources as required
System security ensures the integrity, confidentiality and availability of data
is maintained; use of passwords, maintaining access rights,
and so on

Cambridge IGCSE and O Level Computer Science Teacher's Guide 2


© David Watson and Helen Williams 2021
Answers to Student’s Book

4 • A descriptor is a collection of information about devices.


• Descriptors include the vendor ID, product ID and serial number of a device.
• If a device doesn’t have a unique serial number associated with it, the OS will treat the
device as new every time it is plugged into a USB port.
• When a device is plugged in, descriptors are used to recognise the device and load the
device driver automatically.
5 a • when the computer is powered up, part of the OS needs to be loaded into RAM …
• … this is called the bootstrap (loader)
• start-up is handled by the BIOS …
• … which tells the computer where the storage device that hold the OS can be located
• BIOS is stored on firmware, such as EEPROM
b • BIOS settings are stored on a CMOS chip …
• … which is powered at all times by a battery on the motherboard
• user can change BIOS settings if required but not the BIOS software
6

Cambridge IGCSE and O Level Computer Science Teacher's Guide 3


© David Watson and Helen Williams 2021
Answers to Student’s Book

4.2
1 True False
An assembler translates a high-level language program. 
It is more difficult to write a program in a low-level language. 
Java is an assembly language. 
It is quicker to develop a program using a high-level language. 
You always need a compiler to run a compiled program. 
A program that is interpreted takes a longer time to run than

a compiled program.
Low-level languages are machine dependent. 
2 a • Auto-completion means that an IDE can automatically show the reserved words or
variable names that are available for use, so that the correct one can be picked from
a list.
• Prettyprinting – code editors can colour code parts of a program, for example reserved
words or strings and automatically lay out the program in a meaningful way.
• Translators are supplied as part of the IDE; these can be compilers or interpreters
or both.
b A compiler translates the whole program written in a high-level language into machine
code program. An interpreter executes a program written in a high-level language by
translating then executing each line of the program.
A compiler can produce a file containing the translated machine-code program that can be
executed without the compiler, whereas an interpreter will always need to be present
during the execution of an interpreted program.
c Assembly language programs can be smaller in size and execute tasks more quickly as
fewer instructions are used, programs can also control specialist hardware using
appropriate simple commands.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 4


© David Watson and Helen Williams 2021
Answers to Student’s Book

Answers to exam-style questions


Answers to questions 6 and 7 in this section are example answers for past paper questions. The details of
the relevant past paper can be found with the corresponding exam-style question in the Student’s Book.
1

2 a virus scanner
b defragmentation
c security software
d screen saver
e device driver
3 a provide a platform for the execution of apps and also provides an HCI (human-computer
interface), memory management, security management and management of user accounts,
hardware management (e.g. keyboards and monitors), file management, handles interrupts,
manages multitasking (i.e. running more than one application at a time)
b memory management system which gives the impression that the RAM is larger than it is;
involves moving data into and out of RAM and HDD/SSD
c this occurs when large volumes of data are being moved in and out of HDD; involves a
large number of head movements
d program within the operating system that allows a user to run several applications at the
same time; but only one app is actually 'active' at any given time
e signal sent from a device or software to a processor to temporarily halt the process
currently being run

Cambridge IGCSE and O Level Computer Science Teacher's Guide 5


© David Watson and Helen Williams 2021
Answers to Student’s Book

4 a Graphical user interface (GUI):


• uses pictures or symbols (icons) on screen to allow selection of options
• selection is done via pointing devices or using touchscreen technology
• common system is WIMP when pointing devices used
• Windows manager looks after the interaction between Windows, applications and
pointing devices/cursor position for touchscreen
Command line interface (CLI):
• user has to type in instructions/commands to choose options or launch apps
• user is in direct communication with the computer
• interface/input is via a keyboard and command box
• user needs to learn a number of commands
b and c

Interface Advantages Disadvantages


The user doesn’t need to learn any This type of interface uses up
commands. considerably more computer
It is more user-friendly; icons are used memory than a CLI interface.
to represent applications. The user is limited to the
Graphical
A pointing device (such as a mouse) is icons provided on the screen.
user interface
(GUI) used to click on an icon to launch the It needs an operating system,
application – this is simpler than typing such as Windows, to operate,
in commands OR a touch screen can be which uses up considerable
used where applications are chosen by memory.
simply touching the icon on the screen.
The user is in direct communication The user needs to learn a
with the computer. number of commands to carry
The user is not restricted to a number out basic operations.
Command of pre-determined options. All commands need to be
line interface It is possible to alter computer typed in which takes time and
(CLI) configuration settings. can be error-prone.
It uses a small amount of computer Each command must be typed
memory. in using the correct format,
spelling, and so on.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 6


© David Watson and Helen Williams 2021
Answers to Student’s Book

5 a C – an area in memory that temporarily holds data


b B – software that communicates with the operating system and translates data into a format
that can be printed out
c C – allocating memory to competing applications running on a computer system
d D – multitasking
e A – command line interface (CLI)
f C – a GUI interface makes it easier to use the computer
g C – interrupt
h D – CMOS
i A – any device plugged into the USB port of a computer must have a unique serial number
j B – post-WIMP interfaces make use of the more modern optical mouse to select icons
6 a • A compiler produces a file containing a translated machine-code program;
an interpreter does not.
• An interpreter executes a program written in a high-level language by translating then
executing each line of the program, provided there are no errors in that line.
• A compiler does not execute the program.
b Advantage – compiled programs are smaller in size; source code not included in compiled
file. Disadvantage – longer development time if compilers are used whilst developing code.
c Advantage – easier to edit programs during development. Disadvantage – programs cannot
run without the interpreter.
7 A compiler translates a high-level language into machine code, whilst an assembler translates a
low-level assembly language into machine code. One assembly language instruction usually
translates to one machine code instruction, whereas one high-level language instruction usually
translates to many machine code instructions.
8 a An Integrated Development Environment (IDE) is software that is used by programmers to
aid the writing, editing and development of programs.
b Auto-completion means that an IDE can automatically include matching keywords when
the first keyword is typed. For example, when IF is written in Visual Basic, the IDE
automatically adds the keywords: End If
Auto-correction means that an IDE can automatically correct errors, for example,
underlining the places where syntax errors occur and offering the corrected statement
to use.
Prettyprinting means colour-coding words and adjusting the layout of a program for
readability, for example, always showing reserved words in orange and strings in red.
c • A debugger to test a program in a controlled environment. For example, a separate
report window can be used to display the values of each variable as the program
is running.
• A code editor to type the program and correct errors means that there is no need to exit
the IDE for every alteration during development.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 7


© David Watson and Helen Williams 2021
Answers to Student’s Book

9 As the program has already been written it can be translated using a compiler as the
development has already been done. This means that there would be an executable program
available in binary that can be run on his friend’s computer without the use of any additional
software. Pedro knows that his friend’s internet connection is very slow, and the compiled
program is smaller than the original program so there will be less data to transmit, which
means that it will take less time for the program to arrive and the transmission is more likely to
be successful.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 8


© David Watson and Helen Williams 2021
Cambridge IGCSE™ and O Level Computer Science

Answers to Student’s Book


Exam-style questions and sample answers have been written by the authors. References to
assessment and/or assessment preparation are the publisher’s interpretation of the syllabus
requirements and may not fully reflect the approach of Cambridge Assessment International
Education. Cambridge International recommends that teachers consider using a range of teaching
and learning resources in preparing learners for assessment, based on their own professional
judgement of their students’ needs.
Cambridge Assessment International Education bears no responsibility for the example answers to
questions taken from its past question papers which are contained in this publication.
The questions, example answers, marks awarded and/or comments that appear in this digital
material were written by the author(s). In examination, the way marks would be awarded to
answers like these may be different.

5 The internet and its uses


Answers to activities
5.1
1 a urlexample
b .co
c sample_page
d http
2 a Session cookie:
• temporary cookie
• ceases to exist once browser is closed or website session terminated
• doesn’t actually collect any information from user’s computer
Persistent cookie:
• stored on hard drive of user’s computer …
• … until expiry date reached or user deletes cookie
• remains in operation on user’s computer even when browser closed or website
session terminated
b • allows a website to remember a user’s email address and invoice details so these don’t
have to be typed in each time a user visits a website, which allows a faster log in
• serves as a memory, enabling a website to recognise users every time they visit
the website
• saves user's items in a virtual shopping basket
• tracks internet habits and user’s website history/favourites (bookmarks)/
recommendations made
• stores customer payment details (in secure format)
• stores user preferences
• allows progress in online games/quizzes to be stored

Cambridge IGCSE and O Level Computer Science Teacher's Guide 1


© David Watson and Helen Williams 2021
Answers to Student’s Book

• allows social networking sites to recognise certain preferences and browsing history
• allows different languages to be used on web pages automatically/personalised web
pages stored
• indicates if customer is new or returning
3
Feature Internet World Wide Web

It is possible to send and receive emails 

Makes use of http protocols 

Uses URLs to specify the locations of websites and



web pages

Resources can be accessed by using web browsers 

Makes use of TCP and IP 

4 • they record data about the user …


• … such as browsing activity, purchases and preferences …
• … IP addresses and geographical location
• they store marketing data which allows adverts to target user
5.2
1 a

b If block 4 is hacked and any data is changed, then the hash value for the block will change;
this will result in the chain being broken since block 5 can no longer point to block 4.
2 • cryptocurrency uses cryptography to track transactions
• cryptocurrency is decentralised unlike digital currencies which are centralised
• traditional digital currencies are regulated by central banks and governments
• unlike normal digital currencies, cryptocurrency transactions are publicly available and can
be tracked/money monitored
• cryptocurrency uses blockchaining

Cambridge IGCSE and O Level Computer Science Teacher's Guide 2


© David Watson and Helen Williams 2021
Answers to Student’s Book

5.3
1 a b c
Three from:
brute force attacks to crack passwords make passwords difficult to
crack and change them often
data interception tapping into networks to obtain use private lines/networks and
information encrypt all data
denial of service ‘… which cause it to crash use a malware checker, firewalls
attack and email filters
hacking illegal access to a computer firewalls and passwords
system (including biometrics)
malware (worms, deletion or altering of data use up-to-date anti-malware
viruses, spyware, …) software
phishing legitimate-looking emails which don’t open links in emails, use
contain links to fake websites up-to-date browsers, look out for
https, check if url looks
legitimate
pharming code on HDD/SSD or server use anti-virus software to detect
which redirects browser to fake website tampering, check
website without user’s spelling of websites
knowledge
social engineering cybercriminal creates social be aware of scam text messages,
situation that can lead a victim phone calls, memory sticks left
to dropping their guard using: lying around on purpose, and
instant messaging, scareware, so on
phishing, baiting or phone calls

2 • worm: type of stand-alone virus that can replicate itself with the intention of spreading to
other computers/networks; often uses networks to search out computers with weak security
• ransomware: programs that encrypt data on a user’s computer; a decryption key is sent
back to the user once they pay a sum of money (ransom); they are often sent via a Trojan
horse or by social engineering
• Trojan horse: malicious programs often disguised as legitimate-looking software; they
replace all or part of the legitimate software with the intent of carrying out some harm to
the user’s computer system

Cambridge IGCSE and O Level Computer Science Teacher's Guide 3


© David Watson and Helen Williams 2021
Answers to Student’s Book

3 a i a date of birth – relatively easy to find or guess


ii too close to name of a pet – easy to crack
iii uses his own name in the password – makes it relatively easy to guess
b ensure at least eight characters are used, made up of upper-case and lower-case letters,
numbers and other keyboard characters; passwords should be changed on a regular basis
c if the computer can be accessed by other people, then it is not a good idea to store
passwords on the computer itself since these could be found by another user
5.4
1 a 25-May-2000 – weak password because it is just a date
b Pas5word – one of the ten most used passwords!
c ChapTer@06 – strong password with letters, numbers and other characters
d AbC*N55! – strong password with letters, numbers and other characters
e 12345X – weak password since it is easy to guess/crack
2 a make use of levels of access; for example, level 1: passenger information,
level 2: airport staff, level 3: senior staff only – use passwords and user IDs
b make use of:
• strong passwords and user IDs
• firewalls
• scan for malware at all times
• don’t allow plug-in devices at information desks
• don’t allow internet access from information desks
5.5
1 a • as soon as motion detector recognises a person, a camera automatically photographs
the face of the person
• software scans face for key features and creates an electronic image/file
• the file is compared to the database containing face scans of authorised people
• if key features match database data then entry is allowed …
• … otherwise entry is denied
b finger/thumb print, voice recognition using a microphone
2 Benefits: Drawbacks:
• more secure system since only certain • a person’s voice can be recorded to
people can be recognised as authorised overcome the security system
drivers • low accuracy; doesn’t understand verbal
• safer since driver doesn’t need to look at commands
screens/dials to select options or look at • change of voice (e.g. due to a cold) can
key data make recognition 'hit and miss'
• relatively inexpensive technology • sometimes there is a need to remember
certain commands to make system work

Cambridge IGCSE and O Level Computer Science Teacher's Guide 4


© David Watson and Helen Williams 2021
Answers to Student’s Book

5.6
1 a two-step verification
b proxy server
c privacy settings
d SSL
e firewall
f DNS
g biometrics
h authentication
i social engineering
j pharming
2 A browser requests an SSL/TLS digital certificate from the website it is trying to access. This is
sent from the web server to the user’s browser, containing a public key which can be used to
authenticate the website. Once the digital certificate is authenticated, the browser lets the web
server know, and secure communication can begin.
3 a Three from:
• Are there spelling or grammar errors?
• Does the email FROM address look like it is real?
• Is the domain name in the email address spelt correctly, or does it exactly match the
real company?
• Is the email addressed to you?
• Is there a clickable link? If so, what address does the link point to when you hover over
it? (DO NOT CLICK THE LINK!) It may not match the expected website.
• If it claims to be from a real company, log into your account with the company without
using the link.
b Three from:
• poor spelling and grammar
• not addressed to the user
• WW and Co does not look like a real company
• the email address which this is from does not look like a real or reputable company
• there is no further information in the email, such as details about the company itself
• reputable companies would not expect a customer to click on a link in an email to pay
an account
• does not look professional

Cambridge IGCSE and O Level Computer Science Teacher's Guide 5


© David Watson and Helen Williams 2021
Answers to Student’s Book

Answers to exam-style questions


1 a i A cookie is a small file stored on a user’s computer; they are sent by a website to a
browser when a user visits the site.
ii Session cookies are stored in a temporary memory on the computer; they don’t collect
any information from the user’s computer and don’t identify the user; they cease to
exist when the browser is closed or the user terminates the session with the website.
Persistent cookies are stored on the hard drive of the user’s computer; they remain
stored until an expiry date is reached or the user deletes the cookie; they remain in
operation on the user’s computer even when the browser is closed or the website
session has been terminated; they remove the need to type in login details every time
a website is visited.
iii Three from:
• allows a website to remember a user’s email address and invoice details so these
don’t have to be typed in each time a user visits a website, which allows a faster
log in
• serves as a memory, enabling a website to recognise users every time they visit the
website
• saves users items in a virtual shopping basket
• tracks internet habits and user’s website history/favourites (bookmarks)/
recommendations made
• stores user preferences
• allows progress in online games/quizzes to be stored
• allows social networking sites to recognise certain preferences and browsing
history
• allows different languages to be used on web pages automatically/personalised
web pages stored
• indicates if customer is new or returning
2 a • Spyware is software that gathers information by monitoring activity on a user's
computer. It can gather information by finding information such as bank account
details and passwords stored on the computer or within web browser cookies. Spyware
called keyloggers can record what a user types and which websites they visit. The
gathered information is then sent back to the person who created or sent the software,
which can be used for fraudulent purposes.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 6


© David Watson and Helen Williams 2021
Answers to Student’s Book

b Two step verification – extra security that means that even if passwords are stolen
criminals cannot gain access to the bank account. It requires some biometric
identification – this would limit access to specified employees only.
c • checks for any unusual network traffic and blocks access to the local network
• can be used to only allow specified external connections, so that all traffic is blocked
apart from these specified sites
• any known undesirable sites can be added to a list of blocked network sites
d • passwords/biometrics
• levels of access
• proxy servers
• physical security methods – e.g. PCS in locked rooms, etc.
3

Cambridge IGCSE and O Level Computer Science Teacher's Guide 7


© David Watson and Helen Williams 2021
Answers to Student’s Book

4 a Order: C, E, A, B, D
b • student places finger on scanner
• map of fingerprints taken and converted to digital image
• data sent to a computer
• fingerprint map compared to those stored
• if recognised, the database is updated to show student present (including time and
date of entry)
• on leaving, the same process is carried out and the database is again updated to show
the date/time student left the school premises
5 a Four from:
• instant messaging – links embedded in messages to fake websites
• scareware – pop-up message claiming, for example, user’s computer is infected with a
virus and user downloads the fake virus checker
• emails/phishing – apparently genuine emails sent out which contain links to
fake websites
• baiting – cybercriminal leaves malware-infected memory stick so that it can be easily
'found'; once inserted into a computer, the malware is transferred
• phone calls – so-called IT professional calls a user on their mobile phone claiming their
device has been compromised and they are advised to download software which lets
the cybercriminal take over their device
b • Stage 1 – victim is identified and necessary information is gathered
• Stage 2 – victim is targeted by the chosen method
• Stage 3 – attack on victim takes place and information is gathered or disruption to their
system done
• Stage 4 – when cybercriminal has achieved their goal, all traces of the attack
are removed
c i digital currency exists purely in a digital format; there is no physical money
(fiat currency); digital currency involves electronic transfer of funds
ii if a hacker accessed a block and changed anything (for example, an amount
of money) …
• … the hash value of the block would change
• this means that all blocks beyond the hacked block would now be invalid because
the chain would be broken
• use of 'proof-of-work' is necessary before a block can be added to the chain …
• … thus preventing a hacker quickly creating a new block to complete the chain

Cambridge IGCSE and O Level Computer Science Teacher's Guide 8


© David Watson and Helen Williams 2021
Answers to Student’s Book

6 a Used for layout of content – this structure is defined by HTML tags, e.g. for each heading
and paragraph text.
b browser
Internet Protocol address (IP address)
web server
Hypertext Markup Language (HTML)
7 a SSL is a security protocol:
• it encrypts any data that is sent
• it uses/sends digital certificates …
• … which are sent to the user’s browser …
• … that contains the gallery’s public key …
• … that can be used to authenticate the gallery
• once the digital certificate is authenticated, the transaction can begin
b True False
Statement
() ()

Firewalls are only available as hardware devices 

Firewalls allow a user to set rules for network traffic 

Firewalls will automatically stop all malicious traffic 

Firewalls only examine traffic entering a network 

Firewalls encrypt all data that is transmitted around a network 

Firewalls can be used to block access to certain websites 

Cambridge IGCSE and O Level Computer Science Teacher's Guide 9


© David Watson and Helen Williams 2021
Cambridge IGCSE™ and O Level Computer Science

Answers to Student’s Book


Exam-style questions and sample answers have been written by the authors. References to
assessment and/or assessment preparation are the publisher’s interpretation of the syllabus
requirements and may not fully reflect the approach of Cambridge Assessment International
Education. Cambridge International recommends that teachers consider using a range of teaching
and learning resources in preparing learners for assessment, based on their own professional
judgement of their students’ needs.
Cambridge Assessment International Education bears no responsibility for the example answers to
questions taken from its past question papers which are contained in this publication.
The questions, example answers, marks awarded and/or comments that appear in this digital
material were written by the author(s). In examination, the way marks would be awarded to
answers like these may be different.

6 Automated and emerging technologies


Answers to activities
6.1
a • sensors to detect the presence of a bottle are essential
• level sensors in mixing tank to ensure required volume maintained
• may be other sensors such as temperature and pH
• bottle arrives at bottling station
• sensor sends data back to central computer continuously
• if bottle is present, computer sends signal to actuator to open valve to allow liquid
to fill bottle
• level sensor used to check correct amount of liquid added
• once level sensor reading indicates bottle is full, a signal is sent to computer which
then sends a signal to an actuator to close the valve
• computer then sends signal to actuator to open valve and add measured amount of
carbon dioxide gas
• after two seconds, the gas valve is closed
• next empty bottle arrives and process continues
• bottle now moves to capping station
• again sensor detects bottle and computer sends signal to robot arm to place cap on
bottle and tighten it
• then robot arm retracts
• bottle moves to labelling station
• sensor detects bottle and computer sends signal to actuator to rotate table through
360° as label is glued to bottle
• whole process is continuous
b Advantages:
• faster than a human operator to take any necessary action

Cambridge IGCSE and O Level Computer Science Teacher's Guide 1


© David Watson and Helen Williams 2021
Answers to Student’s Book

• more consistent – each bottle will have almost exactly the same amount of
each ingredient
• less expensive over time as it can replace most of the workforce who would need to
monitor the process 24 hours a day
• less wastage and more efficient use of materials
• higher productivity
Disadvantages:
• expensive to set up
• needs considerable testing
• possible for a set of conditions to occur that were never considered during testing
• automated systems always need enhanced maintenance which can be expensive
• any computerised system is subject to cyberattacks
6.2
• needs camera to pick up parallel lines in parking spot
• extra data needs to be width and length of gap (infrared and ultrasonic sensors can be used
to find these values)
• data needs to indicate that no vehicle is already in the parking space
• parallel parking will use cameras which will search out white (parallel) lines and ensure
that the distance between vehicle and white lines is consistent
6.3
• the computer takes readings from sensors in the car's front bumper …
• … to calculate the distance between the car and the vehicle in front
• the computer takes additional sensor readings to determine the speed of the car
• the computer calculates required safe braking distance
• data from the (given) table is then used and the computer determines if the calculated
braking distance is greater than the data in the table ….
• … if braking distance is greater than safe distance (in table) then brakes are applied and
accelerator/throttle also reduced and warning signal/light produced
• if distance between vehicles is OK then no action taken
6.4
Students should produce a table showing all the advantages and disadvantages of using an
automated weather station. This will require research using the internet or a local weather
station (if it exists). No answer has been supplied because this answer will vary from country to
country and students will need to make their own judgements.
6.5
1 • data gathered automatically from various locations around the world …
• … could all be collated over time and patterns of global weather changes
automatically generated
• automatic projection of key weather data into the future to predict weather could then be
checked for its accuracy (by comparison of predicted weather with ACTUAL weather)

Cambridge IGCSE and O Level Computer Science Teacher's Guide 2


© David Watson and Helen Williams 2021
Answers to Student’s Book

• results of this comparison would allow the climate change model to be modified
2 • three sensors needed: temperature, light and moisture
• all three sensors send data continuously to a microprocessor
• data would need to be converted to digital (using ADC) if necessary
• if temperature readings < pre-set value, the microprocessor sends a signal to
the actuators …
• … to switch on the heating system/close the windows
• if temperature readings >= pre-set value, the microprocessor sends a signal to
the actuators …
• … to operate motors to open windows (and switch off heaters)
• if light level readings < pre-set value, the microprocessor sends a signal to the actuators …
• … to operate motors to open blinds (and turn on artificial lighting)
• if light level readings >= pre-set value, the microprocessor sends a signal to
the actuators …
• … to operate motors to close blinds (and turn off artificial lighting)
• if moisture level readings < pre-set value, the microprocessor sends a signal to
the actuators …
• … to switch on water pump to irrigate soil
• if moisture level readings >= pre-set value, the microprocessor sends signals to
the actuators …
• … to switch off water pumps
• process is continuous
3 • cameras read road signs (60 kph) and software converts the images into a text file
• … which allows the microprocessor to interpret road signs
• if the car’s speed > 60 kph, the microprocessor sends a signal to the actuators …
• … to operate motors to apply the brakes and/or reduce throttle position
• if the car’s speed < 60 kph, the microprocessor sends a signal to the actuators …
• … to operate motors to increase throttle position
• sensors in the car’s bumpers/fenders will ensure a safe distance between car and vehicle in
front is maintained (by applying brakes and altering throttle as necessary)
• the Sat Nav calculates the car’s position on a map
• data is sent to a central computer which checks optimum driving conditions
• if present driving is not the same as stored driving parameters, then computer sends signals
to actuators to change gears and apply brakes as necessary
4 Parts i and ii
Step 1

Cambridge IGCSE and O Level Computer Science Teacher's Guide 3


© David Watson and Helen Williams 2021
Answers to Student’s Book

A sensor detects a vehicle and sends a signal to instruct a camera to capture an image of
the front of the vehicle (often an infrared camera is used to give a clearer image and for use
at night).
Step 2
a An algorithm is used to locate and isolate the number plate from the image taken by the
camera. This algorithm also takes into account the size of the number plate and any
damage or orientation.
b

c Each character is then recognised using optical character recognition (OCR) software. The
characters are converted into a string of editable text by the software.
d This text string is then stored on a database.
Step 3
Once all of this has happened, the car park barrier is raised and the motorist is issued with a
ticket. The ticket shows the date and time of entering the car park.
Step 4
When the motorist returns to the car park, they insert their ticket into a machine which
calculates the car park charges. The payment is registered on the database.
The motorist then drives to the exit barrier and the ANPR system again reads the number plate
and checks its database. If the number plate is recognised (and payment made), the exit barrier
is raised.
iii Advantages:
• no need to employ car park security guards which saves money
• much faster system than having to check a ticket at the exit; car parks can issue tickets
on entry, but this ticket is simply used for payment purposes by the motorist before
leaving the car park and isn’t used at the exit since payment will now be linked to the
number plate on the car
• can be used to automatically control the entry and exit to a car park or private roads
• can be used as a security system; preventing illegal parking and preventing
unauthorised access to private car parks
Disadvantages:
• there is a lack of manned security car park surveillance which could lead to vandalism
(and other crimes) since nobody is checking on a regular basis; CCTV is often used,
but this is often just used 'after the event'
• invasion of privacy issues due to the recording of driver’s number plates
• damaged or very dirty number plates won’t be recognised by the system
• number plate cloning; the ANPR system only recognises the number plate and not the
car, so it is possible for a car to be fitted with a cloned number plate thus by-passing
car park security, for example

Cambridge IGCSE and O Level Computer Science Teacher's Guide 4


© David Watson and Helen Williams 2021
Answers to Student’s Book

6.6
Each student should produce a presentation in the form of a table which highlights the
advantages and disadvantages of immersive games consoles. The table should include research
into which sensors are used (for example, accelerometers, proximity, magnetic field and
pressure), together with a description of the function of each sensor identified.
6.7
1 a i flow sensors, temperature sensors
ii light sensors, infrared/motion sensors
iii infrared/motion sensors, cameras, pressure sensors
b i Advantages, two from:
• faster response to non-optimum conditions
• more precise monitoring
• greater consistency of product(s)
• 24/7 monitoring
Disadvantages:
• expensive to set up initially and to maintain
• may not respond well to unusual conditions
ii Advantages, two from:
• saves money on unnecessary lighting
• completely automated system
• better control of lighting
Disadvantages, two from:
• expensive to set up
• needs expertise to program the lights exactly as required
• may require specialist equipment
iii Advantages, two from:
• much safer
• fewer staff needed
• fewer delays caused by people pulling emergency cord if someone has an item
stuck in the door
Disadvantages, two from:
• still requires human monitoring
• expensive to set up and implement
• requires extensive testing to make sure it works

Cambridge IGCSE and O Level Computer Science Teacher's Guide 5


© David Watson and Helen Williams 2021
Answers to Student’s Book

2
Statement True False

Automated systems lead to less consistent results or less



consistent products
Automated systems are more expensive to set up than traditional

manual systems
Automated systems would be quickly overwhelmed by the amount of

data presented to it

Automated systems are inherently less safe than manual systems 

Automated systems generally require enhanced maintenance when



compared to manual systems
Automated systems allow processes to run at optimum conditions at

all times
Software failures, due to unforeseen conditions, are unlikely to impact

on an automated system
Automated systems will react more quickly to unusual

process conditions
6.8
Students to produce a table showing all the advantages and disadvantages of the use of robots
in agriculture. This may involve research using:
• the chapters in this book
• the companion Information and Communication Technology (ICT) book
• the internet.
Typical advantages might include:
• more accurate
• much faster
• less waste (i.e. picking fruit before it is ripe)
• can work 24 hours a day
Typical disadvantages might include:
• expensive to implement
• will take lots of time to train or program to complete tasks successfully
• different conditions or plants may require more retraining, casual workers will lose
their work

Cambridge IGCSE and O Level Computer Science Teacher's Guide 6


© David Watson and Helen Williams 2021
Answers to Student’s Book

6.9
1 Examples:
• harvesting/picking of vegetables and fruit
• weed control
• phenotyping (plant growth and health)
• seed-planting and fertiliser distribution
• autonomous labour-saving devices
Harvesting and picking:
• robots have been designed to do this labour-intensive work; they are more accurate (only
picking ripe fruit, for example) and much faster at harvesting
• for the reasons above, this leads to higher yields and reduces waste – for example, Vegebot
(Cambridge University) uses cameras to scan, for example, a lettuce and decide whether or
not it is ready to be harvested
• a second camera in Vegebot (near the cutting blades) guides an arm to remove the lettuce
from its stalk with no damage.
Weed control:
• weed management robots can distinguish between a weed and crop using AI
• examples of weed control robots are being used in France (by Mouton Rothschild) to
remove weeds between grape vines in their vineyards; this saves considerably on labour
costs and improves vine growth
• weed control robots use GPS tracking to stay on course to move along the rows of vines
and remove the weeds; a weed removal blade is operated by an actuator under the control
of the controller (microprocessor) in the robot
• very often a drone (flying robot) is used first to do an aerial view of the vineyard, so that a
programmed course of action can be produced, which is then sent to the weed control
robot’s memory.
Phenotyping:
• phenotyping is the process of observing physical characteristics of a plant in order to assess
its health and growth
• robots designed to do phenotyping are equipped with sensors (including spectral sensors
and thermal cameras) that can create a 3D image/model of the plant, thus allowing it to be
monitored for health and growth
• machine learning is used to recognise any issues with leaves (for example, if they have a
blight or have the wrong colour) so that the robot can convey this back to the farmer
• these robots are much more accurate and faster at predicting problems than when done
manually.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 7


© David Watson and Helen Williams 2021
Answers to Student’s Book

Seed-planting and fertiliser distribution:


• drones (flying robots) can produce an aerial image of a farm sending back a 'bird's eye
view' of the crops and land
• they allow seed-planting to be done far more accurately
• they also allow for more efficient fertiliser-spreading to reduce waste and improve
coverage (this is much more efficient than conventional crop spraying)
• drones can also be used in cloud seeding where the drone can add silver iodide crystals to a
cloud forcing it to give up its rainwater
• the drones use a very complex camera system to target seeding and allow fertiliser spraying
Autonomous labour-saving devices:
Several of the devices described above could be referred to as autonomous. The following list
summarises some of the devices which can work independently of humans:
• grass mowers/cutters
• weeding, pruning and harvesting robots
• seeding robots
• fertiliser spraying
• All of these devices use sensors and cameras to go around obstacles, or they can even be
programmed to 'go to sleep' if the weather turns bad.
2

6.10
Essay produced by student on robotics in entertainment including their advantages and
disadvantages.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 8


© David Watson and Helen Williams 2021
Answers to Student’s Book

6.11
1 Advantages Disadvantages
• robots are capable of working in • robots can find it difficult to do 'non-
conditions which may be hazardous standard' tasks (for example,
to humans windscreen being fitted to a car
• robots work 24/7 without the need to stop is cracked)

• robots are less expensive in the long run • robots can lead to higher
(since there will be fewer salaries to pay) unemployment amongst manual
labourers
• robots are more productive than humans
(higher productivity) • there is a risk of deskilling when
robots take over certain tasks (for
• although not necessarily more accurate,
example, welding and paint spraying)
robots are more consistent
• factories can now be moved to
• robots are better suited to boring,
anywhere in the world where
repetitive tasks than humans (therefore
operation costs are lower (leading
less likely to make mistakes)
again to unemployment in some
• there will be less cost in heating and countries)
lighting (robots don’t need good light
• robots are expensive to buy and set up
or warmth)
in the first place

2 Ability to sense its surroundings – two from:


• sensors gather data from surroundings
• allowing robot to recognise its immediate surroundings …
• … giving it the ability to determine size, shape, weight, etc.
Ability to move in some way – two from:
• make use of wheels, cogs, pistons, gears, etc. to carry out turning, twisting, moving,
gripping, lifting, etc.
• mechanical structures made up of motors, hydraulic pipes, actuators and circuit boards
• makes use of electronic components
• uses end-effectors to carry out different tasks
A perceived intelligence:
• have a controller which determines the action to be taken to perform a task
• controllers can be programmed to allow the robot to do certain tasks
3 autonomous
sensors
cameras
actuators
light detecting and ranging/radar and ultrasonics
lasers

Cambridge IGCSE and O Level Computer Science Teacher's Guide 9


© David Watson and Helen Williams 2021
Answers to Student’s Book

4 sensors
microprocessor
environment
end-effectors
controller
programs
repetitive
adaptive
5 a • sensors can use radar/sonar to detect objects under the sea
• cameras take images which allow device to be recognised
• if ship recognised, then microprocessor sends signals to actuators to operate
digital cameras
• actuators also used to operate electric motors in undersea robots to allow them to move
around the shipwreck
b i • sensors can be used to recognise samples
• data sent to microprocessor after digital conversion (using ADC)
• if rock samples recognised, microprocessor sends signals to actuators to …
• … stop robot’s motors
• … to operate 'claws' to take samples of rock
ii camera used to recognise terrain, recognise potential rock samples and to allow
manoeuvring safely
c Advantages include:
• harsh environment which is dangerous to humans
• more precise than humans
• can operate non-stop
• no need for any humans to be present (useful on long journeys, such as visit to Mars
which takes several years)
Disadvantages include:
• expensive devices to design, test and manufacture
• difficult to repair such devices remotely if they break down
• as with any robot, they are limited to the functions programmed in (although some
ability to reprogram will exits – they may not have the necessary attachments to carry
out a newly required task)
d Could be used in defusing bombs, clean-up operations in nuclear plants (for example,
Chernobyl), etc.
6.12
a knowledge base
b explanation system
c expert system shell
d robotics
e rules base

Cambridge IGCSE and O Level Computer Science Teacher's Guide 10


© David Watson and Helen Williams 2021
Answers to Student’s Book

6.13
1 artificial intelligence
cognitive
expert systems
explanation system
inference engine
search engine
inference rules
2 a • Is there anything showing on the screen?
• Can sound be heard through internal loud speakers?
• If external speakers are plugged into another computer, do they work?
• Are the connections between the speakers and the computer OK?
(or any series of logical questions)
b • oil and mineral prospecting
• diagnosis of patient’s illness
• tax and financial calculations
• strategy games, such as chess
• logistics (parcel deliveries)
• identification of plants, animals and chemicals (for example)
3 a • sub-set of AI
• algorithms are trained and learn from past experiences and examples
• offer fast and accurate outcomes due to very powerful processing capability
• ability to manage and analyse considerable volumes of complex data
• machines learn through data acquisition to solve problems
• can make decisions without being programmed to do so
b AI Machine learning
this is the practice of getting a machine to
represents simulated intelligence
make decisions without being
in machines
programmed to do so
the aim is to make machines that learn
the aim is to build machines which are
through data acquisition, so that they can
capable of thinking like humans
solve new problems

c • use web scraping to find key data in websites (search bots)


• redundant data (collaboration filtering) removed
• relationship between key words typed in and key words following collaboration
filtering is used to train the model
• these searches are evaluated to further refine the search engine model

Cambridge IGCSE and O Level Computer Science Teacher's Guide 11


© David Watson and Helen Williams 2021
Answers to Student’s Book

Answers to exam-style questions


1 a Advantages:
• robots don’t need good lighting or working temperatures
• robots can work 24/7
• lower wage bill in the long term
• higher productivity
• fewer errors made
• leaves humans to do more skilled work
Disadvantages:
• expensive to maintain and repair
• expensive to set up initially
• need to pay redundancy money to workers
b • sensors (proximity) to detect presence of humans
• on sensing a human, the robot will automatically stop its activity
• verbal warning made by robot to indicate its presence

Cambridge IGCSE and O Level Computer Science Teacher's Guide 12


© David Watson and Helen Williams 2021
Answers to Student’s Book

2 • accelerometers
• to measure and respond to tilting of device
• to respond to forward/backward and side-to-side movement
• proximity sensors
• used in smart touch pads …
• … to detect hand/finger positions
• embedded accelerometers and other sensors in game consoles
• allow increased human interaction with the game …
• … giving a more immersive games experience
3 a • data from proximity sensor compared to pre-set value
• pre-set value shows minimum distance
• if sensor value is the same/lower
• then the microprocessor sends a signal to actuators to stop the robot
• if sensor value higher
• then no action is taken
• whole process is continuous
b i • light sensors in offices
• light sensors and infrared/motion sensors in offices and corridors
• if a person is detected entering an office or corridor, a signal is sent by
microprocessor to turn on the lights
• if light sensor value < stored value for office the microprocessor sends signal to
turn on lights
ii Advantages:
• less expensive, because lights only on when office or corridor occupied
• longer bulb life because switched on for less time
• possible to program light displays if required
Disadvantages:
• expensive to set up initially
• will require more maintenance than a manual system

Cambridge IGCSE and O Level Computer Science Teacher's Guide 13


© David Watson and Helen Williams 2021
Answers to Student’s Book

4 a Expert
Task Control Monitor
system
automatic control of the atmosphere in a large greenhouse

(to ensure ideal growing conditions)

self-parking system in a car 

playing a strategy game, such as chess 

an automatic weather station sending data to pilots flying



near an airport
a 24/7 check on patients in an intensive care unit of

a hospital

automatic system used to diagnose the illness of a patient 

automatic closing and opening of the doors on a train 

fault identification in electronic devices together with



suggested actions to rectify the fault

b Four from:
• explanation system informs user of the expert system’s reasoning behind its
conclusions and recommendations
• inference engine is a type of search engine used in an expert system that examines the
knowledge base for information that matches the queries
• knowledge base is a repository of facts which contain all the knowledge of the expert
system; it is composed of a collection of objects and attributes
• rules base is a collection of inference rules used to draw conclusions, based on inputs
• user interface is a method whereby the expert system interacts with the user; the
interaction can be through dialogue boxes or command prompts; questions are often
simple Yes/No responses and are based on responses to previous questions
5 a • sensors (infrared, pressure) indicate the presence of a person trying to leave/enter
the train
• cameras can also be used to check that nobody is trapped in the doors
• sensors send data back to a microprocessor …
• … after being converted to digital (using an ADC)
• camera data is put through an algorithm which determines if a person is trapped in
a door
• if camera or sensor data indicate a trapped person …
• … a signal is sent to actuators to operate motors to open doors/halt the closing of doors
• if sensors and camera detect no presence of passenger in door area, …
• … signals are sent to actuators to operate motors to close doors
• the train is then able to move

Cambridge IGCSE and O Level Computer Science Teacher's Guide 14


© David Watson and Helen Williams 2021
Answers to Student’s Book

b • can be fully automatic/no need to manually check every door


• it is safer since no one can get trapped and train can’t move off …
• … until all sensors indicate no passenger presence
• faster response to 'dangerous' situations
c • allows driver to make a manual check on whether it is safe to move off (a double
safety check)
• gives passengers confidence if they know there is a manual back-up safety system
d i autonomous means driverless, no human operators
ii Sensors:
• cameras to recognise signals on the track
• radar and ultrasonics to sense the environment and build up a 3D picture of
surroundings
• use of LiDaR, laser systems and GPS to track position
Actuators:
• to apply brakes to stop train
• to operate accelerator to control speed of train
• to open and close doors
iii Advantages of autonomous trains Disadvantages of autonomous trains
improves the punctuality of the trains ever-present fear of hacking into the
vehicle’s control system
reduced running costs (fewer staff are system doesn’t work well with very busy
required) services (at the moment)
improves safety because human error high capital costs and operational costs
is removed initially (that is, buying the trains,
expensive signalling and control
equipment and the need to train staff)
minimises energy consumption since ensuring passenger behaviour is
there is better control of speed and an acceptable particularly during busy times
optimum service requires less energy (for example, jamming doors open on
(trains stuck in stations still use energy) trains, standing too near the edge of
platforms, and so on)
possible to increase the frequency of passenger reluctance of the new
trains (automated systems allow for technology
shorter times between trains)
easier to change train scheduling (for no drivers mean there will be a need for
example, more trains during busier times) CCTV to monitor railway stations

Cambridge IGCSE and O Level Computer Science Teacher's Guide 15


© David Watson and Helen Williams 2021
Answers to Student’s Book

6 a Ability to sense their surroundings:


• this is done via sensors (such as light, pressure, temperature, acoustic, and so on)
• sensors allow a robot to recognise its immediate environment and gives it the ability to
determine things like size, shape or weight of an object, detect if something is hot or
cold, and so on; all sensor data is sent to a microprocessor or computer
Have a degree of movement:
• they can make use of wheels, cogs, pistons, gears (etc.) to carry out functions such as
turning, twisting, moving backwards/forwards, gripping or lifting
• they are mechanical structures made up of many parts (for example, motors, hydraulic
pipes, actuators and circuit boards)
• they contain many electrical components to allow them to function
• can make use of end effectors (different attachments to allow them to carry out specific
tasks such as welding, spraying, cutting or lifting)
Apparent intelligence:
• they have a 'brain' known as a controller which determines the action to be taken to
perform a certain task (the controller relies on data sent from sensors or cameras, for
example)
b Independent robots:
• have no direct human control (they are said to be autonomous; for example, an
autonomous vehicle)
• can replace the human activity totally (no human interaction is required for the robot to
function fully)
Dependent robots:
• have a human interfacing directly with the robot (the human interface may be a
computer or a control panel)
• can supplement, rather than totally replace, the human activity (for example, in a car
assembly plant where both humans and robots work together to produce a car)

Cambridge IGCSE and O Level Computer Science Teacher's Guide 16


© David Watson and Helen Williams 2021
Answers to Student’s Book

8 a end effector
b inference engine
c autonomous
d machine learning
e automated systems
f artificial intelligence
g chatbots
h search bot/web crawler
i robotics
j cognitive
k attributes
l knowledge base
m drone
n controller
o inference rules

Cambridge IGCSE and O Level Computer Science Teacher's Guide 17


© David Watson and Helen Williams 2021
Cambridge IGCSE™ and O Level Computer Science

Answers to Student’s Book


Exam-style questions and sample answers have been written by the authors. References to
assessment and/or assessment preparation are the publisher’s interpretation of the syllabus
requirements and may not fully reflect the approach of Cambridge Assessment International
Education. Cambridge International recommends that teachers consider using a range of teaching
and learning resources in preparing learners for assessment, based on their own professional
judgement of their students’ needs.
Cambridge Assessment International Education bears no responsibility for the example answers to
questions taken from its past question papers which are contained in this publication.
The questions, example answers, marks awarded and/or comments that appear in this digital
material were written by the author(s). In examination, the way marks would be awarded to
answers like these may be different.

7 Algorithm design and problem solving


Answers to activities
7.1
For example, for a step tracking app:
• Input a 3-axis accelerometer senses my steps
• Process totals the steps for each day
• Output the total number of steps taken so far
• Storage the number of steps taken each day
7.2

7.3
Amount 100
TotalPrice 350
Discount 0.2
FinalPrice 280
Name "Nikki"
Message "Hello Nikki"
7.4
OUTPUT "Please enter a mark "
INPUT Mark

Cambridge IGCSE and O Level Computer Science Teacher's Guide 1


© David Watson and Helen Williams 2021
Answers to Student’s Book

IF Mark < 0 OR Mark > 20


THEN
OUTPUT "Invalid Mark"
ELSE
IF Mark > 9
THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
ENDIF
7.5
CASE OF Day
1 : OUTPUT "Sunday"
2 : OUTPUT "Monday"
3 : OUTPUT "Tuesday"
4 : OUTPUT "Wednesday"
5 : OUTPUT "Thursday"
6 : OUTPUT "Friday"
7 : OUTPUT "Saturday"
OTHERWISE OUTPUT "Error in day number"
ENDCASE
7.6
Purpose: Display the largest number
Processes:
• Input two numbers
• Compare the two numbers
• Display the largest number with a suitable message
Output if 7 and 18 input: 18 is the largest
7.7
1 Telephone number – presence check (to ensure something is entered), length check (to check
the number is not too long or short), or format check (to make sure number matches the style of
national telephone numbers).
Pupil's name – presence check (to ensure something is entered) and length check (i.e. between
2 and 30 letters, to check the name is of a reasonable length).
Part number – presence check (to ensure something is entered) and format check (to make sure
data matches the character/number style XXX999).
2 OUTPUT "Please enter age of child "
INPUT ChildAge
OUTPUT "Please enter height of child in centimetres"
INPUT ChildHeight

Cambridge IGCSE and O Level Computer Science Teacher's Guide 2


© David Watson and Helen Williams 2021
Answers to Student’s Book

IF ChildAge < 8 OR ChildAge > 11 OR ChildHeight < 110 OR


ChildHeight > 150
THEN
IF ChildAge < 8
THEN
OUTPUT "Too young"
ENDIF
IF ChildAge > 11
THEN
OUTPUT "Too old"
ENDIF
IF ChildHeight < 110
THEN
OUTPUT "Too small"
ENDIF
IF ChildHeight > 150
THEN
OUTPUT "Too tall"
ENDIF
ELSE
OUTPUT "Child can ride"
ENDIF
3 OUTPUT "Please enter your password "
REPEAT
INPUT Password
IF LENGTH(Password) > 12 OR LENGTH(Password) < 8
THEN
IF LENGTH(Password) > 12
THEN
OUTPUT "Password is too long, please re-enter "
ELSE
OUTPUT "Password is too short, please re-enter "
ENDIF
ENDIF
UNTIL LENGTH(Password) <= 12 AND LENGTH(Password) >= 8

Cambridge IGCSE and O Level Computer Science Teacher's Guide 3


© David Watson and Helen Williams 2021
Answers to Student’s Book

7.8
Telephone number – the number needs to be the one that is required as well as having the
necessary characteristics.
Pupil's name – the name needs to be the one that is associated with the pupil.
Part number – a part number could have the required format but not be for the part intended.
7.9
For example:
Normal test data: 7, 34, 55, 67, 74, 83, 21, 45, 72, 64; Expected result: 54.2
(Other values acceptable.)

7.10
For example:
Erroneous test data: −7, 1001; Expected result: both values rejected
(Other values acceptable.)
7.11
1 Boundary test data for 100 is: 100, 101; Expected result: 100 accepted, 101 rejected
2 Normal test data: 2, 14, 15, 6, 7, 13, 20, 4, 10, 9; Expected result: 10
Normal test data: 17, 13, 15, 15, 14, 16, 2, 8, 7, 6; Expected result: 11.3
Erroneous test data: −7, 23; Expected result: both values rejected
Boundary test data: −1, 0 and 20, 21
Expected results: −1 rejected, 0 accepted and 20 accepted, 21 rejected
7.12
Answer in chapter (page 285).

Cambridge IGCSE and O Level Computer Science Teacher's Guide 4


© David Watson and Helen Williams 2021
Answers to Student’s Book

7.13

A B C X OUTPUT

0 0 100 Enter your ten values

1 4 4 4

2 8 8

3 19 19

4 17

5 3 3

6 11

7 6

8 1 1

9 13

10 9 19 1

Cambridge IGCSE and O Level Computer Science Teacher's Guide 5


© David Watson and Helen Williams 2021
Answers to Student’s Book

7.14

Temperature
First Last Index Swap Temp
[1] [2] [3] [4] [5] [6] [7] [8]
1 8 1 FALSE 35 31 32 36 39 37 42 38

TRUE 35 31 35

2 TRUE 35 32 35

5 39 39 37 39

7 42 38 42

7 1 FALSE

6 TRUE 39 38 39

6 1 FALSE

Cambridge IGCSE and O Level Computer Science Teacher's Guide 6


© David Watson and Helen Williams 2021
Answers to Student’s Book

7.15
Sample data: −1, −7, −11, −19, −3, −20, −9, −4, −6, −8

A B C X OUTPUT

0 0 100

1 -1

2 -7 -7

3 -11 -11

4 -19 -19

5 -3

6 -20 -20

7 -9

8 -4

9 -6

10 0 -3

0 -20

The highest value is −1 not zero.


7.16
−1000001(or any number less than this) and 1000001(or any number greater than this) will fail.
7.17
A ← 0
OUTPUT "Enter your ten values"
INPUT X
B ← X
C ← X
REPEAT
INPUT X
IF X > B
THEN
B ← X
ENDIF
IF X < C
THEN
C ← X
ENDIF
A ← A + 1
UNTIL A = 9
OUTPUT B, C

Cambridge IGCSE and O Level Computer Science Teacher's Guide 7


© David Watson and Helen Williams 2021
Answers to Student’s Book

A B C X OUTPUT

0 -97 -97 -97

1 12390 12390

2 0

3 77

4 359

5 -2

6 -89

7 5000

8 21

9 67

12390,-97

7.18
0, 26
Expected results rejected – erroneous data
1, 25
Expected results: Your tickets cost 20
Your tickets cost 400 – extreme data
9, 10
Expected results: Your tickets cost 180
Your tickets cost 180 – normal data
19, 20
Expected results: Your tickets cost 342
Your tickets cost 320 – normal data
Extra test data:
0, 1
Expected results: 0 rejected
1 Your tickets cost 20 – boundary data lower bound
26, 25
Expected results: 26 rejected
25 Your tickets cost 400 – boundary data upper bound
-30, 200
Expected results rejected – erroneous data

Cambridge IGCSE and O Level Computer Science Teacher's Guide 8


© David Watson and Helen Williams 2021
Answers to Student’s Book

7.19
1 Change FOR Test ← 1 to 4 // outer loop for the tests
to FOR Test ← 1 to 2 // outer loop for the tests
remove 3 : SubjectName ← "English" and 4 : SubjectName ← "IT"
change FOR StudentNumber ← 1 TO 600
to FOR StudentNumber ← 1 TO 5
change SubjectAverage ← SubjectTotal / 600
to SubjectAverage ← SubjectTotal / 5
change OverallAverage ← OverallTotal / 2400
to OverallAverage ← OverallTotal / 10
The code should now look like this:
// initialisation of overall counters
OverallHighest ← 0
OverallLowest ← 100
OverallTotal ← 0
FOR Test ← 1 to 2 // outer loop for the tests
// initialisation of subject counters
SubjectHighest ← 0
SubjectLowest ← 100
SubjectTotal ← 0
CASE OF Test
1 : SubjectName ← "Maths"
2 : SubjectName ← "Science"
ENDCASE
FOR StudentNumber ← 1 TO 5 // inner loop for the students
REPEAT
OUTPUT "Enter Student", StudentNumber, "’s mark for ", SubjectName
INPUT Mark
UNTIL Mark < 101 AND Mark > -1
IF Mark < OverallLowest THEN OverallLowest ← Mark
IF Mark < SubjectLowest THEN SubjectLowest ← Mark
IF Mark > OverallHighest THEN OverallHighest ← Mark
IF Mark > SubjectHighest THEN SubjectHighest ← Mark
OverallTotal ← OverallTotal + Mark
SubjectTotal ← SubjectTotal + Mark
NEXT StudentNumber
SubjectAverage ← SubjectTotal / 5
OUTPUT SubjectName
OUTPUT "Average mark is ", SubjectAverage
OUTPUT "Highest Mark is ", SubjectHighest
OUTPUT "Lowest Mark is ", SubjectLowest
NEXT Test
OverallAverage ← OverallTotal / 10
OUTPUT "Overall Average is ", OverallAverage
OUTPUT "Overall Highest Mark is ", OverallHighest
OUTPUT "Overall Lowest Mark is ", OverallLowest

Test data (sample – yours might be different): 1, 99, −1, 101, 20, 80, 30, 70, 40, 60, 50, 50

Cambridge IGCSE and O Level Computer Science Teacher's Guide 9


© David Watson and Helen Williams 2021
Answers to Student’s Book

2 Trace table:

Subject Overall Output


Student Subject
Test Mark
Number Name Av High Low Total Av High Low Total
0 100 0
1 0 100 0

1 1 1 1 1 1 1 1
Enter student 1’s
mark for Maths

2 99 99 100 99 100
Enter student 2’s
mark for Maths

3 -1
Enter student 3’s
mark for Maths

101
Enter student 3’s
mark for Maths

20 120 120
Enter student 3’s
mark for Maths

4 80 200 200
Enter student 4’s
mark for Maths

5 30 230 230
Enter student 5’s
mark for Maths
Maths
Average mark is 46
46
Highest mark is 99
Lowest mark is 1
2 0 100 0

1 70 70 70 70 300
Enter student 1’s
mark for English

2 40 40 110 340
Enter student 2’s
mark for English

3 60 60 170 400
Enter student 3’s
mark for English

4 50 50 220 450
Enter student 4’s
mark for English

5 50 50 270 500
Enter student 5’s
mark for English
English
Average mark is 54
54
Highest mark is 70
Lowest mark is 40
Overall average
mark is 50
50
Overall highest
mark is 99
Overall lowest
mark is 1

Cambridge IGCSE and O Level Computer Science Teacher's Guide 10


© David Watson and Helen Williams 2021
Answers to Student’s Book

7.20
1 Total ← 0
FOR Counter ← 1 TO 10
REPEAT
OUTPUT "Enter positive number "
INPUT Number
UNTIL Number > 0
Total ← Total + Number
NEXT Counter
Average ← Total / 10
OUTPUT "Average is ", Average
OUTPUT "Total is ", Total
2 Total ← 0
Counter ← 0
REPEAT
REPEAT
OUTPUT "Enter positive number, -1 to finish "
INPUT Number
UNTIL Number > 0 OR Number = -1
IF Number <> -1
THEN
Total ← Total + Number
Counter ← Counter + 1
ENDIF
UNTIL Number = -1
Average ← Total / Counter
OUTPUT "Average is ", Average
OUTPUT "Total is ", Total
3 For 1, I chose a FOR … NEXT loop because it has a fixed number of iterations.
For 2, I chose a REPEAT … UNTIL loop because there must be at least one number in the list
but the number of iterations is unknown.
Answers to exam-style questions
Answers to questions 8 and 9 in this section are example answers for past paper questions. The details of
the relevant past paper can be found with the corresponding exam-style question in the Student’s Book.
1 • Inputs – the data used by the system that needs to be entered while the system is active
• Processes – the tasks that need to be performed using the input data and any other
previously stored data
• Outputs – information that needs to be displayed or printed for the users of the system
• Storage – data that needs to be stored in files on an appropriate media for use in the future

Cambridge IGCSE and O Level Computer Science Teacher's Guide 11


© David Watson and Helen Williams 2021
Answers to Student’s Book

3 a Diners – range check 2 to 12 inclusive, presence check and type check of integer
Bill – range check 10 to 500 inclusive, presence check and type check of real
b Test data (sample – yours might be different):
• Normal data: 5 diners and a bill of $90.00
Expected result: $18.00
• Normal data: 8 diners and a bill of $69.00
Expected result: $8.63
c Test data (sample – yours might be different):
• Abnormal data: 15 diners and a bill of $5.00
Expected result: both values rejected
d • Boundary data for lower bounds 1 diner and 2 diners and bills of $9.99 and $10.00
Expected result: 1 and $9.99 both values rejected, 2 and $10.00 $5.00
• Boundary data for upper bounds 12 diners and 13 diners and bills of $500.00 and
$500.01
Expected result: 13 and $500.01 both values rejected, 12 and $500.00 $41.67
4 Validation – the automated checking by a program that data is reasonable before it is accepted
into a computer system
Verification – checking that data has been accurately copied from another source and input into
a computer or transferred from one part of a computer system to another
5 Name:
Validation checks:
• presence to ensure name is entered
• length check to ensure there are not too many letters
Verification check – yes to ensure that the name entered is the one intended and there are no
typing errors

Cambridge IGCSE and O Level Computer Science Teacher's Guide 12


© David Watson and Helen Williams 2021
Answers to Student’s Book

Date of birth:
Validation checks:
• presence to ensure date of birth is entered
• format check to ensure that all the components of the data are in range
• range check to ensure that the value for the date is realistic
Verification check – yes to ensure that the date entered is the one intended and there are no
typing errors
Password:
Validation checks:
• presence to ensure password is entered
• length check to ensure there are the appropriate number of characters
• format check for any special rules, for example at least one digit
Verification check – yes to ensure that the password entered is the one intended and there are
no typing errors
Phone number:
Validation checks:
• presence to ensure phone number is entered
• length check to ensure there are the appropriate number of digits/characters
• format check for any special rules, for example must start with +44
Verification check – yes to ensure that the phone number entered is the one intended and there
are no typing errors
6 a Counter Accept Reject Length Breadth Size OUTPUT

0 0 0

1 1 15 10 150

2 2 20 17 340

3 1 32 10

4 2 30 35

5 3 30 15 450

6 3 30 28 840

7 4 25 25 625

8 4 20 15 300

9 5 40 20 800

10 5 12 10 120 5 5

Cambridge IGCSE and O Level Computer Science Teacher's Guide 13


© David Watson and Helen Williams 2021
Answers to Student’s Book

b • input length and breadth of 10 parcels


• check length and breadth less than 30 for each parcel
• calculate size and check size less than 600 for each parcel
• increment the number of parcels accepted or the number of parcels rejected
• output number of parcels accepted and number of parcels rejected
c Length and breadth must be less than or equal to 30. Size must be less than or equal to 600.
7 a • Error 1: Counter ← 1 should be Total ← 0
• Error 2: UNTIL Number < 0 should be UNTIL Number > 0
• Error 3: Total ← Total + Counter should be Total ← Total
+ Number
• Error 4: Counter ← Counter + 1 is not required
• Error 5: OUTPUT Total should be after the end of the loop
• Error 6: NEXT Number should be NEXT Counter
b Total ← 0
FOR Counter ← 1 TO 10
REPEAT
OUTPUT "Enter a positive whole number "
INPUT Number
UNTIL Number > 0

Total ← Total + Number


NEXT Counter
OUTPUT Total
c Test data: 1, 0, 67, 10, 22, −10, 3, 7, 2, 8, 1, 9 (sample – yours might be different).
Counter Number Total OUTPUT
0
1 1 1
2 0
67 68
3 10 78
4 22 100
5 -10
3 103
6 7 110
7 2 112
8 8 120
9 1 121
10 9 130 130

Cambridge IGCSE and O Level Computer Science Teacher's Guide 14


© David Watson and Helen Williams 2021
Answers to Student’s Book

d Test data: 1, 0, 67, 10, 22, −10, 3, 7, 2, 8, 1, 9 (sample – yours might be different).
1 extreme, 0 erroneous, 67 normal, 10 normal, 22 normal, −10 erroneous, 3 normal,
7 normal, 2 normal, 8 normal, 1 normal and 9 normal.
8 a Number1 Number2 Sign Answer OUTPUT
5 7 + 12 12
6 2 - 4 4
4 3 * 12 12
7 8 ? 0
0 0 / (0)

b CASE Sign OF
ꞌ+ꞌ : Answer ← Number1 + Number2
ꞌ-ꞌ : Answer ← Number1 - Number2
ꞌ*ꞌ : Answer ← Number1 * Number2
ꞌ/ꞌ :
Answer ← Number1 / Number2
OTHERWISE Answer ← 0
ENDCASE
9 a To ensure no changes are made on input, because the details do not have fixed values and
there is no clear set of rules that can be used for validation.
The programmer could ask the contributor to type in each detail twice and then check that
both values are equal. If they are not equal, then the input should be rejected.
b Email – check for @ to ensure that it is an email address. Password – length check to
ensure sufficient characters have been entered.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 15


© David Watson and Helen Williams 2021
Cambridge IGCSE™ and O Level Computer Science

Answers to Student’s Book


Exam-style questions and sample answers have been written by the authors. References to
assessment and/or assessment preparation are the publisher’s interpretation of the syllabus
requirements and may not fully reflect the approach of Cambridge Assessment International
Education. Cambridge International recommends that teachers consider using a range of teaching
and learning resources in preparing learners for assessment, based on their own professional
judgement of their students’ needs.
Cambridge Assessment International Education bears no responsibility for the example answers to
questions taken from its past question papers which are contained in this publication.
The questions, example answers, marks awarded and/or comments that appear in this digital
material were written by the author(s). In examination, the way marks would be awarded to
answers like these may be different.

8 Programming
Answers to activities
8.1
Python
print("Hello World")
Visual Basic
Module Module1
Sub Main()
Console.WriteLine("Hello World")
Console.ReadKey()
End Sub
End Module
Java
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World");
}
}
8.2
Pseudocode
DECLARE radius, length : REAL
CONSTANT PI = 3.142
Python
# Python does not require separate declarations...
# ...values are simply assigned as required
# Python does not differentiate between constants and variables
radius = 10.0
length = 10.0
PI = 3.142
Visual Basic
Dim radius As Decimal
Dim length As Decimal
Const PI As Decimal = 3.142
Java
final double PI = 3.142;
double radius;

Cambridge IGCSE and O Level Computer Science Teacher's Guide 1


© David Watson and Helen Williams 2021
Answers to Student’s Book

double length;
8.2a
Python
StoreIngeger = int(input())
StoreDecimal = float(input())
StoreLetter = input()
StoreText = input()
StoreBoolean = bool(input())
Visual Basic
StoreInteger = Integer.parse(Console.Readline())
StoreDecimal = Decimal.parse(Console.Readline())
StoreLetter = Console.Readline()
StoreText = Console.Readline()
StoreBoolean = Bool.parse(Console.Readline())

Java
int StoreInteger = myObj.nextInt();
double StoreDecimal = myObj.nextDouble();
char StoreLetter = myObj.next);
String StoreText = myObj.next();
Boolean StoreBoolean = myObj.nextBoolean();

Cambridge IGCSE and O Level Computer Science Teacher's Guide 2


© David Watson and Helen Williams 2021
Answers to Student’s Book

8.3
Python
ConstPi = 3.142
radius = float(input("Please enter the radius of the cylinder "))
length = float(input("Please enter the length of the cylinder "))
volume = radius * radius * length * ConstPi
print("Volume of the cylinder is ", volume)
Visual Basic
Module Module1
Public Sub Main()
Dim radius As Decimal
Dim length As Decimal
Dim volume As Decimal
Const PI As Decimal = 3.142
Console.Write("Please enter the radius of the cylinder ")
radius = Decimal.Parse(Console.ReadLine())
Console.Write("Please enter the length of the cylinder ")
length = Decimal.Parse(Console.ReadLine())
volume = radius * radius * length * PI
Console.WriteLine("Volume of cylinder is " & volume)
Console.ReadKey()
End Sub
End Module
Java
import java.util.Scanner;
class Cylinder
{
public static void main(String args[])
{
Scanner myObj = new Scanner(System.in);
final double PI = 3.142;
double radius;
double length;

System.out.println("Please enter the radius of the cylinder ");


radius = myObj.nextDouble();
System.out.println("Please enter the length of the cylinder ");
length = myObj.nextDouble();
double volume = radius * radius * length * PI;
System.out.println("Volume of cylinder is " + volume);

}
}

Cambridge IGCSE and O Level Computer Science Teacher's Guide 3


© David Watson and Helen Williams 2021
Answers to Student’s Book

8.4
Python
num = int(input("Please enter a number "))
if num >= 100:
print ("100 or over")
else:
print ("less than 100")
Visual Basic
Module Module1
Sub Main()
Dim num As Integer
Console.Write("Please enter a number ")
num = Integer.Parse(Console.ReadLine())
If num >= 100 Then
Console.WriteLine("100 or over")
Else
Console.WriteLine("less than 100")
End If
Console.ReadKey()
End Sub
End Module
Java
import java.util.Scanner;
class Activity_8_4
{
public static void main(String args[])
{
Scanner myObj = new Scanner(System.in);
int num;

System.out.println("Please enter a number ");


num = myObj.nextInt();
if (num >= 100){
System.out.println("100 or over");
} else {
System.out.println("Less than 100");
}
}
}

Cambridge IGCSE and O Level Computer Science Teacher's Guide 4


© David Watson and Helen Williams 2021
Answers to Student’s Book

8.5
Python
num = int(input("Please enter a number "))
if num == 1:
print ("Number equals 1")
elif num == 2:
print ("Number equals 2")
elif num == 3:
print ("Number equals 3")
elif num == 4:
print ("Number equals 4")
else: print ("Invalid number")
Visual Basic
Module Module1
Sub Main()
Dim num As Integer
Console.Write("Please enter a number ")
num = Integer.Parse(Console.ReadLine())
Select Case num
Case 1
Console.WriteLine("Number equals 1")
Case 2
Console.WriteLine("Number equals 2")
Case 3
Console.WriteLine("Number equals 3")
Case 4
Console.WriteLine("Number equals 4")
Case Else
Console.WriteLine("Invalid number")
End Select
Console.ReadKey()
End Sub
End Module
Java
import java.util.Scanner;
class Activity_8_5_Java
{
public static void main(String args[])
{
Scanner myObj = new Scanner(System.in);
int num;

System.out.println("Please enter a number ");


num = myObj.nextInt();
switch (num){
case 1:
System.out.println("Number equals 1");
break;
case 2:
System.out.println("Number equals 2");
break;
case 3:
System.out.println("Number equals 3");
break;
case 4:
System.out.println("Number equals 4
break;
default:
System.out.println("Invalid number");
}
}
}

Cambridge IGCSE and O Level Computer Science Teacher's Guide 5


© David Watson and Helen Williams 2021
Answers to Student’s Book

8.6
Python
#count controlled loop
for Counter in range (1, 30, 3):
print(Counter)
#condition controlled loop
Counter = 1
while Counter < 30:
print(Counter)
Counter = Counter + 3
Visual Basic
Module Module1
Sub Main()
Dim Counter As Integer
'count controlled loop
For Counter = 1 To 30 Step 3
Console.WriteLine(Counter)
Next
'condition controlled loop
Counter = 1
Do
Console.WriteLine(Counter)
Counter = Counter + 3
Loop Until Counter >= 30
Console.ReadKey()
End Sub
End Module
Java
class Activity_8_6_Java
{
public static void main(String args[])
{
int Counter;
//count controlled loop
for (Counter = 1; Counter <= 30; Counter = Counter + 3){
System.out.println(Counter);
}

//condition controlled loop


Counter = 1;
do {
System.out.println(Counter);
Counter = Counter + 3;
}
while (Counter <=30);

}
}

Cambridge IGCSE and O Level Computer Science Teacher's Guide 6


© David Watson and Helen Williams 2021
Answers to Student’s Book

8.7
Python
Count = 0
TotalSackWeight = 0
SackWeight = float(input("Enter weight of next sack, -1 to finish "))
while SackWeight != -1:
Count = Count + 1
TotalSackWeight = TotalSackWeight + SackWeight
SackWeight = float(input("Enter weight of next sack, -1 to finish "))
print ("Total number of sacks is ", Count)
print ("Total weight of sacks is ", TotalSackWeight)
Visual Basic
Module Module1
Sub Main()
Dim Count As Integer
Dim SackWeight As Decimal
Dim TotalSackWeight As Decimal
Count = 0
TotalSackWeight = 0
Console.Write("Please enter weight of next sack ")
SackWeight = Decimal.Parse(Console.ReadLine())
While SackWeight <> -1
Count = Count + 1
TotalSackWeight = TotalSackWeight + SackWeight
Console.Write("Please enter weight of next sack ")
SackWeight = Decimal.Parse(Console.ReadLine())
End While
Console.WriteLine("Total number of sacks is " & Count)
Console.WriteLine("Total weight of sacks is " & TotalSackWeight)
Console.ReadKey()
End Sub
End Module
Java
import java.util.Scanner;
class Activity_8_7_Java
{
public static void main(String args[])
{
Scanner myObj = new Scanner(System.in);
int Count = 0;
double SackWeight;
double TotalSackWeight = 0;

System.out.println("Please enter weight of next sack ");


SackWeight = myObj.nextDouble();
while (SackWeight != -1) {
Count ++;
TotalSackWeight = TotalSackWeight + SackWeight;
System.out.println("Please enter weight of next sack ");
SackWeight = myObj.nextDouble();
}
System.out.println("Total number of sacks is " + Count);
System.out.println("Total weight of sacks is " + TotalSackWeight);

}
}

Cambridge IGCSE and O Level Computer Science Teacher's Guide 7


© David Watson and Helen Williams 2021
Answers to Student’s Book

8.8
Python
MyName = input("Please enter your full name ")
print ("There are ", len(MyName), " characters in your name")
print ("The first three characters are are ", MyName[0:3])
print ("Upper Case ", MyName.upper())
print ("Lower Case ", MyName.lower())
Visual Basic
Module Module1
Public Sub Main()
Dim MyName As String
Console.Write("Please enter your full name ")
MyName = Console.ReadLine()
Console.WriteLine("There are " & MyName.Length() & " characters in your
name")
Console.WriteLine("The first three characters are are " &
MyName.Substring(0, 3))
Console.WriteLine("Upper case " & UCase(MyName))
Console.WriteLine("Lower case " & LCase(MyName))
Console.ReadKey()
End Sub
End Module
Java
import java.util.Scanner;
class Activity_8_8_Java
{
public static void main(String args[])
{
Scanner myObj = new Scanner(System.in);
System.out.println("Please enter your full name ");
String MyName = myObj.next();
System.out.println("There are " + MyName.length() + " characters in
your name");
System.out.println("The first three characters are " +
MyName.substring(0,3));
System.out.println("Upper case " + MyName.toUpperCase());
System.out.println("Lower case " + MyName.toLowerCase());

}
}
8.9
Python
Number1 = float(input ("Enter first number "))
Number2 = float(input ("Enter second number "))
print("Add ", Number1 + Number2)
print("Subtract ", Number1 - Number2)
print("Multiply ", Number1 * Number2)
print("Divide ", Number1 / Number2)
print("Raise to the power of ", Number1 ** Number2)
Number3 = int(input ("Enter third number "))
print("Number3 * (Number1 + Number2) ", Number3 * (Number1 + Number2))
print("Number3 * (Number1 - Number2) ", Number3 * (Number1 - Number2))
print("(Number1 + Number2) ^ Number3 ", (Number1 + Number2) ** Number3)
Visual Basic
Module Module1
Public Sub Main()
Dim Number1 As Decimal
Dim Number2 As Decimal
Dim Number3 As Integer
Console.Write("Please enter the first number ")
Number1 = Decimal.Parse(Console.ReadLine())
Console.Write("Please enter the second number ")
Number2 = Decimal.Parse(Console.ReadLine())
Console.WriteLine("Add " & (Number1 + Number2))

Cambridge IGCSE and O Level Computer Science Teacher's Guide 8


© David Watson and Helen Williams 2021
Answers to Student’s Book

Console.WriteLine("Subtract " & (Number1 - Number2))


Console.WriteLine("Multiply " & (Number1 * Number2))
Console.WriteLine("Divide " & (Number1 / Number2))
Console.WriteLine("Raise to the power of " & (Number1 ^ Number2))
Console.Write("Please enter the third number ")
Number3 = Integer.Parse(Console.ReadLine())
Console.WriteLine("Number3 * (Number1 + Number2) " & (Number3 *
(Number1 + Number2)))
Console.WriteLine("Number3 * (Number1 - Number2) " & (Number3 *
(Number1 - Number2)))
Console.WriteLine("(Number1 + Number2) ^ Number3 " & ((Number1 +
Number2) ^ Number3))
Console.ReadKey()
End Sub
End Module
Java
import java.util.Scanner;
import java.lang.Math;
class Activity_8_9_Java
{
public static void main(String args[])
{
Scanner myObj = new Scanner(System.in);
System.out.println("Please enter first number ");
double Number1 = myObj.nextDouble();
System.out.println("Please enter second number ");
double Number2 = myObj.nextDouble();
System.out.println("Add " + (Number1 + Number2));
System.out.println("Subtract " + (Number1 - Number2));
System.out.println("Multiply " + (Number1 * Number2));
System.out.println("Divide " + (Number1 / Number2));
System.out.println("Raise to the power of " +
(Math.pow(Number1,Number2)));
System.out.println("Please enter third number ");
int Number3 = myObj.nextInt();
System.out.println("Number3 *(Number1 + Number2) " + (Number3 *(Number1
+ Number2)));
System.out.println("Number3 *(Number1 - Number2) " + (Number3 *(Number1
- Number2)));
System.out.println("(Number1 + Number2) ^ Number3 " +
(Math.pow((Number1 + Number2),
Number3)));

}
}
8.10
Python
Number1 = float(input ("Enter first number "))
Number2 = float(input ("Enter second number "))
if (Number1 == Number2):
print("Both numbers are equal ")
elif (Number1 > Number2):
print("Numbers are not equal, Number 1 is the largest and Number 2 is the
smallest")
else:
print("Numbers are not equal, Number 2 is the largest and Number 1 is the
smallest")
Number3 = float(input ("Enter third number "))
if (Number1 == Number2) and (Number2 == Number3):
print("All numbers are equal ")

Cambridge IGCSE and O Level Computer Science Teacher's Guide 9


© David Watson and Helen Williams 2021
Answers to Student’s Book

elif Number1 == Number2:


if Number1 > Number3:
print("Numbers 1 and 2 are equal largest, Number 3 is smallest")
else:
print("Numbers 1 and 2 are equal smallest, Number 3 is largest")
elif Number2 == Number3:
if Number2 > Number1:
print("Numbers 2 and 3 are equal largest, Number 1 is smallest")
else:
print("Numbers 2 and 3 are equal smallest, Number 1 is largest")
elif Number3 == Number1 :
if Number3 > Number2:
print("Numbers 1 and 3 are equal largest, Number 2 is smallest")
else:
print("Numbers 1 and 3 are equal smallest, Number 2 is largest")

else:
print("All numbers are not equal")
if (Number1 > Number2 and Number2 > Number3):
print("Number 1 is the largest and Number 3 is the smallest")
if (Number1 > Number3 and Number3 > Number2):
print("Number 1 is the largest and Number 3 is the smallest")
if (Number2 > Number1 and Number1 > Number3):
print("Number2 is the largest and Number3 is the smallest")
if (Number2 > Number3 and Number3 > Number1):
print("Number2 is the largest and Number1 is the smallest")
if (Number3 > Number2 and Number2 > Number1):
print("Number3 is the largest and Number1 is the smallest")
if (Number3 > Number1 and Number1 > Number2):
print("Number3 is the largest and Number2 is the smallest")

Visual Basic
Module Module1
Public Sub Main()
Dim Number1 As Decimal
Dim Number2 As Decimal
Dim Number3 As Decimal

Console.Write("Please enter the first number ")


Number1 = Decimal.Parse(Console.ReadLine())
Console.Write("Please enter the second number ")
Number2 = Decimal.Parse(Console.ReadLine())
If (Number1 = Number2) Then
Console.WriteLine("Both numbers are equal ")
Else
Console.WriteLine("Both numbers are not equal")
If (Number1 > Number2) Then
Console.WriteLine("Number1 is largest and Number2 is
smallest")
Else
Console.WriteLine("Number2 is largest and Number1 is
smallest")
End If
End If
Console.Write("Please enter the third number ")
Number3 = Decimal.Parse(Console.ReadLine())
If Number1 = Number2 And Number2 = Number3 Then
Console.WriteLine("All numbers are equal ")
ElseIf Number1 = Number2 Then
If Number1 > Number3 Then
Console.WriteLine("Numbers 1 and 2 are equal largest, Number 3
is smallest")
Else
Console.WriteLine("Numbers 1 And 2 are equal smallest, Number
3 is largest")
End If

Cambridge IGCSE and O Level Computer Science Teacher's Guide 10


© David Watson and Helen Williams 2021
Answers to Student’s Book

ElseIf Number2 = Number3 Then


If Number2 > Number1 Then
Console.WriteLine("Numbers 2 and 3 are equal largest, Number 1
is smallest")
Else
Console.WriteLine("Numbers 2 And 3 are equal smallest, Number
1 is largest")
End If

ElseIf Number3 = Number1 Then


If Number3 > Number2 Then
Console.WriteLine("Numbers 1 and 3 are equal largest, Number 2
is smallest")
Else
Console.WriteLine("Numbers 1 And 3 are equal smallest, Number
2 is largest")
End If

Else
If Number1 > Number2 And Number2 > Number3 Then
Console.WriteLine("Number1 is largest and Number3 is
smallest")
End If
If Number1 > Number2 And Number3 > Number2 And Number1 > Number3
Then
Console.WriteLine("Number1 is largest and Number2 is
smallest")
End If
If Number2 > Number3 And Number3 > Number1 Then
Console.WriteLine("Number2 is largest and Number1 is
smallest")
End If
If Number2 > Number1 And Number1 > Number3 And Number1 > Number3
Then
Console.WriteLine("Number2 is largest and Number3 is
smallest")
End If
If Number3 > Number2 And Number2 > Number1 Then
Console.WriteLine("Number3 is largest and Number1 is
smallest")
End If
If Number3 > Number1 And Number1 > Number2 And Number3 > Number2
Then
Console.WriteLine("Number3 is largest and Number2 is
smallest")
End If
End If
Console.ReadKey()
End Sub
End Module

Java
import java.util.Scanner;
class Activity_8_10_Java
{
public static void main(String args[])
{
Scanner myObj = new Scanner(System.in);
System.out.println("Please enter first number ");
double Number1 = myObj.nextDouble();
System.out.println("Please enter second number ");
double Number2 = myObj.nextDouble();
if (Number1 == Number2) {
System.out.println("Both numbers are equal");
} else {
System.out.println("Both numbers are not equal");
if (Number1 > Number2) {

Cambridge IGCSE and O Level Computer Science Teacher's Guide 11


© David Watson and Helen Williams 2021
Answers to Student’s Book

System.out.println("Number1 is the largest and Number2 is the


smallest");
} else {
System.out.println("Number2 is the largest and Number1 is the
smallest");
}
}
System.out.println("Please enter third number ");
double Number3 = myObj.nextDouble();
if(Number1 == Number2 && Number2 == Number3) {
System.out.println("All numbers are equal");
}
else if(Number1 == Number2) {
if (Number1 > Number3) {
System.out.println("Numbers 1 and 2 are equal largest, Number
3 is smallest");
} else {
System.out.println("Numbers 1 and 2 are equal smallest, Number
3 is largest");
}}

else if(Number2 == Number3) {


if (Number2 > Number1) {
System.out.println("Numbers 2 and 3 are equal largest, Number
1 is smallest");
} else {
System.out.println("Numbers 2 and 3 are equal smallest, Number
1 is largest");
}}

else if(Number3 == Number1) {


if (Number3 > Number2) {
System.out.println("Numbers 1 and 3 are equal largest, Number
2 is smallest");
} else {
System.out.println("Numbers 1 and 3 are equal smallest, Number
2 is largest");
}}

else {
if (Number1 > Number2 && Number2 > Number3) {
System.out.println("Number1 is the largest and Number3 is the
smallest");
}
if (Number1 > Number3 && Number3 > Number2) {
System.out.println("Number1 is the largest and Number2 is the
smallest");
}
if (Number2 > Number1 && Number1 > Number3) {
System.out.println("Number2 is the largest and Number3 is the
smallest");
}
if (Number2 > Number3 && Number3 > Number1) {
System.out.println("Number2 is the largest and Number1 is the
smallest");
}
if (Number3 > Number2 && Number2 > Number1) {
System.out.println("Number3 is the largest and Number1 is the
smallest");
}
if (Number3 > Number1 && Number1 > Number2) {
System.out.println("Number3 is the largest and Number2 is the
smallest");
}
}
}
}

Cambridge IGCSE and O Level Computer Science Teacher's Guide 12


© David Watson and Helen Williams 2021
Answers to Student’s Book

8.11, 8.12 and 8.13


Python
ClassHigh = 0
ClassLow = 100
ClassTotal = 0
NumberOfTests = 5
NumberOfSubjects = 6
ClassSize = 20
for Student in range (1, ClassSize + 1):
StudentHigh = 0
StudentLow = 100
StudentTotal = 0
for Subject in range (1, NumberOfSubjects + 1):
SubjectHigh = 0
SubjectLow = 100
SubjectTotal = 0
for Test in range (1, NumberOfTests + 1):
Mark = int(input("Please enter mark "))
if (Mark > SubjectHigh):
SubjectHigh = Mark
if (Mark < SubjectLow):
SubjectLow = Mark
SubjectTotal = SubjectTotal + Mark
SubjectAverage = SubjectTotal / NumberOfTests
print ("Average mark for Subject ", Subject, " is ", SubjectAverage)
print ("Highest mark for Subject ", Subject, " is ", SubjectHigh)
print ("Lowest mark for Subject ", Subject, " is ", SubjectLow)
if SubjectHigh > StudentHigh:
StudentHigh = SubjectHigh
if SubjectLow < StudentLow:
StudentLow = SubjectLow
StudentTotal = StudentTotal + SubjectTotal
StudentAverage = StudentTotal / (NumberOfTests * NumberOfSubjects)
print ("Average mark for Student ", Student, " is ", StudentAverage)
print ("Highest mark for Student ", Student, " is ", StudentHigh)
print ("Lowest mark for Student ", Student, " is ", StudentLow)

if StudentHigh > ClassHigh:


ClassHigh = StudentHigh
if StudentLow < ClassLow:
ClassLow = StudentLow
ClassTotal = ClassTotal + StudentTotal
ClassAverage = ClassTotal / (NumberOfTests * NumberOfSubjects * ClassSize)
print ("Average mark for Class is ", ClassAverage)
print ("Highest mark for Class is ", ClassHigh)
print ("Lowest mark for Class is ", ClassLow)
Visual Basic
Module Module1
Sub Main()
Dim ClassAverage, StudentAverage, SubjectAverage As Decimal
Dim Student, Subject, Test, Mark As Integer
Dim ClassHigh, ClassLow, ClassTotal As Integer
Dim StudentHigh, StudentLow, StudentTotal As Integer
Dim SubjectHigh, SubjectLow, SubjectTotal As Integer
ClassHigh = 0
ClassLow = 100
ClassTotal = 0
'Use of constants enables you to easily change the values for testing
Const NumberOfTests As Integer = 5
Const NumberOfSubjects As Integer = 6
Const ClassSize As Integer = 20
For Student = 1 To ClassSize
StudentHigh = 0
StudentLow = 100
StudentTotal = 0
For Subject = 1 To NumberOfSubjects

Cambridge IGCSE and O Level Computer Science Teacher's Guide 13


© David Watson and Helen Williams 2021
Answers to Student’s Book

SubjectHigh = 0
SubjectLow = 100
SubjectTotal = 0
For Test = 1 To NumberOfTests
Console.Write("Please enter mark ")
Mark = Decimal.Parse(Console.ReadLine())
If Mark > SubjectHigh Then
SubjectHigh = Mark
End If
If Mark < SubjectLow Then
SubjectLow = Mark
End If
SubjectTotal = SubjectTotal + Mark
Next Test
SubjectAverage = SubjectTotal / NumberOfTests
Console.WriteLine("Average mark for Subject " & Subject & " is "
& SubjectAverage)
Console.WriteLine("Highest mark for Subject " & Subject & " is
" & SubjectHigh)
Console.WriteLine("Lowest mark for Subject " & Subject & " is
" & SubjectLow)
If SubjectHigh > StudentHigh Then
StudentHigh = SubjectHigh
End If
If SubjectLow < StudentLow Then
StudentLow = SubjectLow
End If
StudentTotal = StudentTotal + SubjectTotal
Next Subject
StudentAverage = StudentTotal / (NumberOfTests * NumberOfSubjects)
Console.WriteLine("Average mark for Student " & Student & " is " &
StudentAverage)
Console.WriteLine("Highest mark for Student " & Student & " is " &
StudentHigh)
Console.WriteLine("Lowest mark for Student " & Student & " is " &
StudentLow)
If StudentHigh > ClassHigh Then
ClassHigh = StudentHigh
End If
If StudentLow < ClassLow Then
ClassLow = StudentLow
End If
ClassTotal = ClassTotal + StudentTotal
Next Student
ClassAverage = ClassTotal / (NumberOfTests * NumberOfSubjects *
ClassSize)
Console.WriteLine("Average mark for Class is " & ClassAverage)
Console.WriteLine("Highest mark for Class is " & ClassHigh)
Console.WriteLine("Lowest mark for Class is " & ClassLow)
Console.ReadKey()
End Sub
End Module
Java
import java.util.Scanner;
class Activity_8_13_Java
{
public static void main(String args[])
{
Scanner myObj = new Scanner(System.in);
double ClassAverage, StudentAverage, SubjectAverage;
int Student, Subject, Test, Mark;
int ClassHigh, ClassLow, ClassTotal;
int StudentHigh, StudentLow, StudentTotal;
int SubjectHigh, SubjectLow, SubjectTotal;
ClassHigh = 0;
ClassLow = 100;
ClassTotal = 0;

Cambridge IGCSE and O Level Computer Science Teacher's Guide 14


© David Watson and Helen Williams 2021
Answers to Student’s Book

final int NumberOfTests = 5;


final int NumberOfSubjects = 6;
final int ClassSize = 20;

for (Student = 1; Student <= ClassSize ; Student ++) {


StudentHigh = 0;
StudentLow = 100;
StudentTotal = 0;
for (Subject = 1; Subject <= NumberOfSubjects; Subject ++) {
SubjectHigh = 0;
SubjectLow = 100;
SubjectTotal = 0;
for (Test = 1; Test <= NumberOfTests; Test ++) {
System.out.println("Please enter mark ");
Mark = myObj.nextInt();
if (Mark > SubjectHigh) {
SubjectHigh = Mark;
}
if (Mark < SubjectLow) {
SubjectLow = Mark;
}
SubjectTotal = SubjectTotal + Mark ;
}
SubjectAverage = SubjectTotal / NumberOfTests ;
System.out.println("Average mark for subject " + Subject + "
is " + SubjectAverage );
System.out.println("Highest mark for subject " + Subject + "
is " + SubjectHigh);
System.out.println("Lowest mark for subject " + Subject + " is
" + SubjectLow);
if (SubjectHigh > StudentHigh) {
StudentHigh = SubjectHigh;
}
if (SubjectLow < StudentLow) {
StudentLow = SubjectLow;
}
StudentTotal = StudentTotal + SubjectTotal;
}
StudentAverage = StudentTotal / (NumberOfTests * NumberOfSubjects);
System.out.println("Average mark for student " + Subject + " is " +
StudentAverage);
System.out.println("Highest mark for student " + Subject + " is " +
StudentHigh);
System.out.println("Lowest mark for student " + Subject + " is " +
StudentLow);
if (StudentHigh > ClassHigh) {
ClassHigh = StudentHigh;
}
if (StudentLow < ClassLow) {
ClassLow = StudentLow;
}
ClassTotal = ClassTotal + StudentTotal ;
}
ClassAverage = ClassTotal / (NumberOfTests * NumberOfSubjects *
ClassSize);
System.out.println("Average mark for class is " + ClassAverage );
System.out.println("Highest mark for class is " + ClassHigh);
System.out.println("Lowest mark for class is " + ClassLow);

}
}

Cambridge IGCSE and O Level Computer Science Teacher's Guide 15


© David Watson and Helen Williams 2021
Answers to Student’s Book

8.14
Python
def Stars():
print("************")
print("************")
print("************")
Stars()
Visual Basic
Module Module1
Sub Main()
Stars()
Console.ReadKey()
End Sub
Sub Stars()
Console.WriteLine("************")
Console.WriteLine("************")
Console.WriteLine("************")
End Sub
End Module
Java
import java.util.Scanner;
class Activity_8_14_Java
{
static void Stars()
{
System.out.println("***********");
System.out.println("***********");
System.out.println("***********");
}
public static void main(String args[])
{
Stars();

}
}
8.15
Python
def Stars(Number):
for Counter in range(Number):
print("************\n")
Stars(7)
Visual Basic
Module Module1
Sub Main()
Stars(7)
Console.ReadKey()
End Sub
Sub Stars(Number As Integer)
Dim Counter As Integer
For Counter = 1 To Number
Console.WriteLine("************")
Next
End Sub
End Module
Java
import java.util.Scanner;
class Activity_8_14_Java
{
static void Stars(int Number)
{
for (int Counter = 1; Counter <= Number; Counter ++)
{
System.out.println("***********");

Cambridge IGCSE and O Level Computer Science Teacher's Guide 16


© David Watson and Helen Williams 2021
Answers to Student’s Book

}
}
public static void main(String args[])
{
Stars(7);

}
}
8.16
Python
def Fahrenheit (Temperature):
return (1.8 * Temperature + 32)
Answer = Fahrenheit(0)
print (Answer)
Visual Basic
Module Module1
Sub Main()
Dim Answer As Decimal
Answer = Fahrenheit(0)
Console.WriteLine(Answer)
Console.ReadKey()
End Sub
Function Fahrenheit(ByVal Temperature As Decimal)
Return 1.8 * Temperature + 32
End Function
End Module
Java
import java.util.Scanner;
class Activity_8_16_Java
{
static double Fahrenheit (double Temperature)
{
return (Temperature * 1.8 + 32);
}
public static void main(String args[])
{
double Answer = Fahrenheit (0);
System.out.println(Answer);
}
}
8.17
Python
def Test():
Number1 = 10
Number2 = 20
Number3 = 30
Answer = Number1 + Number2
print ("Number1 is now ", Number1)
print ("Number2 is now ", Number2)
print ("Answer is now ", Answer)

Number1 = 50
Number2 = 100
Answer = Number1 + Number2
print ("Number1 is ", Number1)
print ("Number2 is ", Number2)
print ("Answer is ", Answer)
Test()
print ("Number1 is still ", Number1)
print ("Number2 is still ", Number2)
print ("Answer is still ", Answer)
print ("Number3 is ", Number3)

Cambridge IGCSE and O Level Computer Science Teacher's Guide 17


© David Watson and Helen Williams 2021
Answers to Student’s Book

Output from Python:


Number1 is 50
Number2 is 100
Answer is 150
Number1 is now 10
Number2 is now 20
Answer is now 30
Number1 is still 50
Number2 is still 100
Answer is still 150
Traceback (most recent call last):
File "… Hodder/Chapter 8 programs/Activity_8_17_Python.py", line 24, in
<module>
print ("Number3 is ", Number3)
NameError: name 'Number3' is not defined
Visual Basic
Module Module1
Sub Main()
Dim Number1, Number2, Answer As Integer
Number1 = 50
Number2 = 100
Answer = Number1 + Number2
Console.WriteLine("Number1 is " & Number1)
Console.WriteLine("Number2 is " & Number2)
Console.WriteLine("Answer is " & Answer)
Test()
Console.WriteLine("Number1 is still " & Number1)
Console.WriteLine("Number2 is still " & Number2)
Console.WriteLine("Answer is still " & Answer)
Console.WriteLine("Number3 is " & Number3)
Console.ReadKey()
End Sub
Sub Test()
Dim Number1, Number2, Number3, Answer As Integer
Number1 = 10
Number2 = 20
Number3 = 30
Answer = Number1 + Number2
Console.WriteLine("Number1 is now " & Number1)
Console.WriteLine("Number2 is now" & Number2)
Console.WriteLine("Answer is now " & Answer)
End Sub
End Module
Note – the program will not run, try defining Number3 in the main program instead.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 18


© David Watson and Helen Williams 2021
Answers to Student’s Book

Java
import java.util.Scanner;
class Activity_8_17_Java
{
static void Test()
{
int Number1 = 10;
int Number2 = 20;
int Number3 = 30;
int Answer = Number1 + Number2;
System.out.println("Number1 is now " + Number1);
System.out.println("Number2 is now " + Number2);
System.out.println("Answer is now " + Answer);
}
public static void main(String args[])
{
int Number1 = 50;
int Number2 = 100;
int Answer = Number1 + Number2;
System.out.println("Number1 is " + Number1);
System.out.println("Number2 is " + Number2);
System.out.println("Answer is " + Answer);
Test();
System.out.println("Number1 is still " + Number1);
System.out.println("Number2 is still " + Number2);
System.out.println("Answer is still " + Answer);
System.out.println("Number3 is " + Number3);
}
}
Note – the program will not run, try defining Number3 in the main program instead.

8.18
Subject Procedure local variables:
Test, Mark, SubjectAverage, SubjectTotal
Student Procedure local variables:
Subject, StudentAverage, StudentTotal, SubjectHigh, SubjectLow,

Cambridge IGCSE and O Level Computer Science Teacher's Guide 19


© David Watson and Helen Williams 2021
Answers to Student’s Book

8.19
Value1 is 1
Value2 is 3
Value3 is 6.97
8.20
Python
import random
a = int(input ("Enter first integer "))
b = int(input ("Enter second integer "))
AnswerMod = a%b
AnswerDiv = a//b
print(a, "MOD", b, "is", AnswerMod)
print(a, "DIV", b, "is", AnswerDiv)
c = int(random.random() * 200 + 100)
print(c, "is a random number between 100 and 300")
Visual Basic
Module Module1
Sub Main()
Dim a, b, c As Integer
Dim AnswerMod, AnswerDiv As Integer
Console.Write("Please enter the first integer ")
a = Integer.Parse(Console.ReadLine())
Console.Write("Please enter the second number ")
b = Integer.Parse(Console.ReadLine())
AnswerMod = a Mod b
AnswerDiv = a \ b
Console.WriteLine(a & " MOD " & " is " & AnswerMod)
Console.WriteLine(a & " DIV " & " is " & AnswerDiv)
c = CInt(Rnd() * 200 + 100)
Console.WriteLine(c & " is a random integer between 100 and 300")
Console.ReadKey()
End Sub
End Module
Java
import java.util.Scanner;
import java.lang.Math;
import java.util.Random;
class Activity_8_20_Java
{
public static void main(String args[])
{
Scanner myObj = new Scanner(System.in);
System.out.println("Please enter first integer ");
int a = myObj.nextInt();
System.out.println("Please enter second integer ");
int b = myObj.nextInt();

int AnswerMod = a % b;
int AnswerDiv = a / b;

System.out.println(a + " MOD " + b+ " is " + AnswerMod );


System.out.println(a + " DIV " + b + " is " + AnswerDiv );

Random rand = new Random();


int c = rand.nextInt(200) + 100;

System.out.println(c + " is a random integer between 100 and 300");


}
}
8.21
Use the list in 8.1.8 to check for any features not used.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 20


© David Watson and Helen Williams 2021
Answers to Student’s Book

8.22
Python
MyList=[]
for counter in range(10):
MyList.append (int(input("Enter next value")))
print (MyList)
Visual Basic
Module Module1
Sub Main()
Dim MyList(9), Counter As Integer
For Counter = 0 To 9
Console.Write("Enter next value ")
MyList(Counter) = Integer.Parse(Console.ReadLine())
Next
For Counter = 0 To 9
Console.Write(MyList(Counter) & " ")
Next
Console.ReadKey()
End Sub
End Module
Java
import java.util.Scanner;
class Activity_8_22_Java
{
public static void main(String args[])
{
Scanner myObj = new Scanner(System.in);
int MyList[] = new int[10];
int Counter;
for (Counter = 0; Counter <= 9; Counter ++) {
System.out.print("Enter next value ");
MyList[Counter] = myObj.nextInt();
}
for (Counter = 0; Counter <= 9; Counter ++) {
System.out.print(MyList[Counter] + " ");
}
}

}
8.23
Python
MyTable =[]
for ColumnCounter in range(3):
Column =[]
for RowCounter in range(10):
Column.append(int(input("Enter next value ")))
MyTable.append(Column)
print(MyTable)

Visual Basic
Module Module1
Sub Main()
Dim MyTable(9, 2), ColumnCounter, RowCounter As Integer
For ColumnCounter = 0 To 2
For RowCounter = 0 To 9
Console.Write("Enter next value for Column " & ColumnCounter)
MyTable(RowCounter, ColumnCounter) =
Integer.Parse(Console.ReadLine())
Next
Next
For RowCounter = 0 To 9
For ColumnCounter = 0 To 2
Console.Write(MyTable(RowCounter, ColumnCounter) & " ")
Next

Cambridge IGCSE and O Level Computer Science Teacher's Guide 21


© David Watson and Helen Williams 2021
Answers to Student’s Book

Console.WriteLine()
Next
Console.ReadKey()
End Sub
End Module
Java
import java.util.Scanner;
class Activity_8_23_Java
{
public static void main(String args[])
{
Scanner myObj = new Scanner(System.in);
int MyTable[][] = new int[10][3];
int ColumnCounter, RowCounter;
for (ColumnCounter = 0; ColumnCounter <= 2; ColumnCounter ++) {
for ( RowCounter = 0; RowCounter <= 9; RowCounter ++) {
System.out.print("Enter next value for column " +
ColumnCounter);
MyTable[RowCounter][ColumnCounter] = myObj.nextInt();
}
}
for ( RowCounter = 0; RowCounter <= 9; RowCounter ++) {
for ( ColumnCounter = 0; ColumnCounter <= 2; ColumnCounter ++) {
System.out.print( MyTable[RowCounter][ColumnCounter]+ " ");
}
System.out.println();
}
}
}
8.24
Python
# writing to and reading a line of text from a file
MyFile = open ("MyText.txt","w") # open file for writing
TextLine = input("Please enter a line of text ") # enter line of text from
keyboard
MyFile.write(TextLine) # write line of text to file
print("The file contains this line of text")
MyFile = open ("MyText.txt","r")# open file for reading
TextLine = MyFile.read()# read line of text from file
print(TextLine) # output line of text from file
Visual Basic
' writing to and reading from a text file
Imports System.IO
Module Module1
Sub Main()
Dim textLn As String
Dim objMyFileWrite As StreamWriter
Dim objMyFileRead As StreamReader
objMyFileWrite = New StreamWriter("textFile.txt") ' setup file for
writing
Console.Write("Please enter a line of text ")
textLn = Console.ReadLine() ' enter line of text from keyboard
objMyFileWrite.WriteLine(textLn) ' write line of text to file
objMyFileWrite.Close() ' close file after writing line of text
Console.WriteLine("The line of text is ")
objMyFileRead = New StreamReader("textFile.txt") ' setup file for
reading
textLn = objMyFileRead.ReadLine ' read line of text from file
Console.WriteLine(textLn) ' output line of text from file
objMyFileRead.Close() ' close file after reading line of text
Console.ReadLine()
End Sub
End Module

Cambridge IGCSE and O Level Computer Science Teacher's Guide 22


© David Watson and Helen Williams 2021
Answers to Student’s Book

Java
//writing to and reading from a text file
import java.util.Scanner;
import java.io.BufferedReader; // library routines for file handling
import java.io.PrintWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

class TextFile {

public static void main(String[] args) {


Scanner myObj = new Scanner(System.in);
String textLn;
try {
FileWriter myFileWriter = new FileWriter("textFile.txt", false);
PrintWriter myPrintWriter = new PrintWriter(myFileWriter);
// setup file for writing

System.out.println("Please enter a line of text ");


textLn = myObj.next(); //enter line of text from keyboard
myPrintWriter.printf("%s" + "%n", textLn); // write line of text
to file
myPrintWriter.close(); // close file after writing line of text
} catch (IOException e) {
e.printStackTrace();
}

try { // exception handling


FileReader myFileReader = new FileReader("textFile.txt");
BufferedReader myBufferReader = new BufferedReader(myFileReader);
// setup file for reading

textLn = myBufferReader.readLine(); // read line of text from file


System.out.println(textLn); // output line of text from file

myFileReader.close(); // close file after reading line of text

} catch (IOException e) { // exception handling


e.printStackTrace();
}
}

}
8.25
DECLARE TextLine : STRING // variables are declared as normal
DECLARE MyFile : STRING
MyFile ← "MyText.txt"
MyOtherFile ← "MyOtherText.txt"
// reading the line of text from the file
OUTPUT "The file contains this line of text:"
OPEN MyFile FOR READ // opens file for reading
READFILE, TextLine // reads a line of text from the file
CLOSEFILE(MyFile) // closes the file
// writing the line of text to another file
OPEN MyOtherFile FOR WRITE // opens the file for writing
WRITEFILE, TextLine // writes the line of text to the
file
CLOSEFILE(MyFile) // closes the file

Cambridge IGCSE and O Level Computer Science Teacher's Guide 23


© David Watson and Helen Williams 2021
Answers to Student’s Book

Answers to exam-style questions


Answers to question 9 in this section are example answers for past paper questions. The details of
the relevant past paper can be found with the corresponding exam-style question in the Student’s Book.
1 Both types of data store contain values that can be accessed by a program during execution
using the name of the data store. Data stores for variables contain data that may be changed
during the execution of the program. Whereas data stores for constants contain data that may
not be changed during the execution of the program.
2 • Item name: ItemName – string
• Manufacturer: Manufacturer – string
• Description: Description – string
• Number in stock: NumberInStock – integer
• Reorder level: ReorderLevel – integer
• Whether the item is on order or not: OnOrder – Boolean
3 • Sequence – the order that steps in a program are executed. For example, these two
statements need to be in the correct sequence:
INPUT Value
IF Value > 10…
• Selection – allowing the selection of different paths through the steps of a program.
IF Value > 10 THEN … ELSE …
• Iteration – a section of programming code can be repeated under certain conditions.
FOR Value = 1 TO 10
OUTPUT "****"
NEXT
• Totalling – keeping a total that values are added to.
Total = Total + Value
• Counting – keeping a count of the number of times an action is performed.
Count = Count + 1
4 OUTPUT "Please enter password "
INPUT Password
IF (LENGTH(Password) = 10) AND (Password = UCASE(Password))
THEN
OUTPUT "Password meets the rules"
ENDIF
5 A global variable can be used by any part of a program – its scope covers the whole program.
Any variable declared in the main program is a global variable.
A local variable can only be used by the part of the program it has been declared in – its scope
is restricted to that part of the program. Any variable declared within a procedure or function is
a local variable.
An error will occur if an attempt is made to access a local variable outside of its scope.
6 Many programmers find library routines useful because they are fully tested and ready to
incorporate into a program. For example, any string handling routines such as conversion to
lower or upper case, or routines for rounding a value to a fixed number of decimal places.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 24


© David Watson and Helen Williams 2021
Answers to Student’s Book

7 a DECLARE Name : ARRAY[1:10, 1:2] OF STRING


// Table for First name in column 1 and Family Name in
column 2
DECLARE Counter :INTEGER
FOR Index ← 1 TO 10
OUTPUT ("First name ", Name[Index, 1], " Family name ",
Name[Index, 2])
NEXT Index
b DECLARE Name : ARRAY[1:10, 1:2] OF STRING
// Table for First name in column 1 and Family Name in
column 2
DECLARE Index, First, Last : INTEGER
DECLARE Swap : Boolean
DECLARE Temp1, Temp2 : STRING
First ← 1
Last ← 10
REPEAT
Swap ← FALSE
FOR Index ← First TO Last – 1
IF Name[Index, 2] > Name[Index + 1, 2] // Test Family
name in column 2
THEN
Temp2 ←Name[Index, 2]
Temp1 ←Name[Index, 1]
Name[Index, 2] ← Name[Index + 1, 2]
Name[Index, 1] ← Name[Index + 1, 1]
Name[Index + 1, 2] ← Temp2
Name[Index + 1, 1] ← Temp1
Swap ← TRUE // swap both names
ENDIF
NEXT Index
Last ← Last –1
UNTIL (NOT Swap) OR Last = 1
FOR Index ← 1 TO 10
OUTPUT ("First name ", Name[Index, 1], " Family name ",
Name[Index, 2])
NEXT Index

Cambridge IGCSE and O Level Computer Science Teacher's Guide 25


© David Watson and Helen Williams 2021
Answers to Student’s Book

8 DECLARE Message : STRING // variables are declared as normal


DECLARE MessageFile : STRING
MessageFile ← "Message.txt"
// reading the line of text from the file
OUTPUT "The Message is:"
OPEN MessageFile FOR READ // opens file for reading
READFILE, Message // reads a line of text from the file
OUTPUT Message
CLOSEFILE(MessageFile) // closes the file
9 a Loop with 300 repetitions, starting at 1, values input are stored in consecutive locations in
the array Name at the position in the array indexed by the loop counter I
b REPEAT … UNTIL
c OUTPUT "Please enter a number between 0 and 100 inclusive"
INPUT Number
WHILE Number <0 OR Number > 100
OUTPUT "Number out of range. Please enter a number
between 0 and 100 inclusive"
INPUT Number
ENDWHILE
10–12
Important points to note when writing your program:
• There is not one 'correct' solution to this problem. Any solution is acceptable but your
program must:
• perform all the tasks set out in the question.
• use a range of appropriate programming techniques that cover all the tasks set out in
the question. These tasks must be executed by your program in a logical order.
• use appropriate data structures, that have been given meaningful names, to store all the
data mentioned in the question. If any data structures are named in the question, then
those names must be used in your program.
• be fully commented to ensure that it can be understood.
For example, in 10, see the following sample of code:

Cambridge IGCSE and O Level Computer Science Teacher's Guide 26


© David Watson and Helen Williams 2021
Cambridge IGCSE™ and O Level Computer Science

Answers to Student’s Book


Exam-style questions and sample answers have been written by the authors. References to
assessment and/or assessment preparation are the publisher’s interpretation of the syllabus
requirements and may not fully reflect the approach of Cambridge Assessment International
Education. Cambridge International recommends that teachers consider using a range of teaching
and learning resources in preparing learners for assessment, based on their own professional
judgement of their students’ needs.
Cambridge Assessment International Education bears no responsibility for the example answers to
questions taken from its past question papers which are contained in this publication.
The questions, example answers, marks awarded and/or comments that appear in this digital
material were written by the author(s). In examination, the way marks would be awarded to
answers like these may be different.

9 Databases
Answers to activities
Answers to question 3 in this section are example answers for past paper questions. The details of
the relevant past paper can be found with the corresponding exam-style question in the Student’s Book.
9.1
Sample fields for database APPOINTMENT:
• Number of patients: e.g. PatientNumber
• Name of patient: e.g. PatientName
• Time of appointment: e.g. AppointmentTime
• Length of appointment: e.g. Duration
9.2

Cambridge IGCSE and O Level Computer Science Teacher's Guide 1


© David Watson and Helen Williams 2021
Answers to Student’s Book

Cambridge IGCSE and O Level Computer Science Teacher's Guide 2


© David Watson and Helen Williams 2021
Answers to Student’s Book

9.3

9.4
1 Four from:
• Text – a number of characters, for example a person’s name
• Char – a single character, for example M or F for male or female
• Boolean – True or False, for example whether an item has been sold or not
• Integer – a whole number, for example the number of items in stock
• Real – a decimal number, for example the price of an item
• Date/time – for example the date and time of an appointment
2 A single table database contains one table. Each table consists of many records. Every record
has the same number of fields. Every field is given a data type. Examples of data types are
char, Boolean and text. Some fields will have validation rules.
9.5
1 a SELECT FirstName, FamilyName
FROM PATIENT
WHERE Consultant = 'Mr Jones';
b SELECT FirstName, FamilyName
FROM PATIENT
WHERE WardNumber <> 6;
c SELECT FirstName, FamilyName
FROM PATIENT
WHERE DateOfAdmisson = '12/11/2022';
d SELECT FirstName, FamilyName, DateOfAdmission
FROM PATIENT
WHERE DateOfAdmission >= '12/10/2022' AND <= '30/10/2022';
2

Cambridge IGCSE and O Level Computer Science Teacher's Guide 3


© David Watson and Helen Williams 2021
Answers to Student’s Book

9.6
1 a SELECT Count (WardNumber)
FROM PATIENT
WHERE WardNumber = 7;
b SELECT Count (WardNumber)
FROM PATIENT
WHERE WardNumber <> 7;
2

9.7
1 a

i SELECT CubName
FROM CUB
WHERE Six = 'red';
ii SELECT CubName
FROM CUB
WHERE Six = 'red' OR Six = 'blue';
iii SELECT COUNT(Six)
FROM CUB
WHERE Six = 'red';
c SELECT Sum (Badges)
FROM CUB;

Cambridge IGCSE and O Level Computer Science Teacher's Guide 4


© David Watson and Helen Williams 2021
Answers to Student’s Book

9.8
1 a • Family name – text
• Other names – text
• Student ID – text
• Date of Birth – date
• Date of Entry to School – date
• Current Class – date
• Current school year/grade – integer
• Email address – text
b • Family name – verification
• Other names – verification
• Student ID – verification and validation
• Date of Birth – verification and validation
• Date of Entry to School – verification and validation
• Current Class – verification and validation
• Current school year/grade – verification and validation
• Email address – verification and validation
c • Student ID – presence check, length check and format check
• Date of Birth – range check and format check
• Date of Entry to School – range check and format check
• Current Class – format check
• Current school year/grade – format check
• Email address – format check
d Student ID
e Example: five characters, S followed by four digits
f

Cambridge IGCSE and O Level Computer Science Teacher's Guide 5


© David Watson and Helen Williams 2021
Answers to Student’s Book

g i SELECT OtherNames, FamilyName, EmailAddress


FROM STUDENT
ORDER By FamilyName;
ii SELECT OtherNames, FamilyName
FROM STUDENT
ORDER BY CurrentClass, FamilyName;
iii e.g. for year 3 it would be:
SELECT OtherNames, FamilyName, DateOfBirth
FROM STUDENT
WHERE CurrentSchoolYear = 3
ORDER BY CurrentClass;
Similar SQL queries would be used for each different school year group.
Answers to exam-style questions
1 a i 10 records
ii 11 fields
iii No field is suitable to use as a primary key as none of the field values are unique.
b CR
LR
c SELECT *
FROM CAR
WHERE leather AND (silver OR grey);
2 a i • model number – text – used when the field contains numbers and characters
• description – text – suitable for characters
• colour – text – suitable for characters
• size of wheels – integer – wheels are measured in mm in the example so no
decimal places needed, hence integer is best option
• price of model – real – price will often finish with $XX.99, hence real numbers
with decimal required
• still manufactured – Boolean – can only be yes or no, hence Boolean is best option
• number in stock – integer – can only be whole numbers of stock, hence integer
is used
ii • model number – presence check, format check and length check as the field must
contain data; the first two characters should be letters and the last five numbers,
and the number of characters should be seven
• price – range check as the value should not be below a minimum number
• number in stock – range check as this should not fall below zero
iii Model number is suitable to use as a primary key as this uniquely identifies the type
of bicycle.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 6


© David Watson and Helen Williams 2021
Answers to Student’s Book

b For instance, to display the stock of each model number where there are less than 20 bikes
left in stock, ordered by number in stock, we would use:
SELECT ModelNumber, NumberInStock
FROM CYCLE
WHERE NumberInStock < 20
ORDER BY NumberInStock;

To calculate the total number of bikes in stock we would use:


SELECT SUM NumberInStock
FROM CYCLE;
SELECT is used to specify the fields that will be displayed.
FROM defines which table the fields are taken from.
WHERE is an optional command that can add certain conditions on the records to
be displayed.
SUM is an optional command used with SELECT to specify fields whose values will be
added together.
ORDER BY is an optional command that defines the order in which records will
be displayed.
3 a • Fields: 5
• Records: 8
b • Validation check 1: format check
• Validation check 2: presence check

Cambridge IGCSE and O Level Computer Science Teacher's Guide 7


© David Watson and Helen Williams 2021
Cambridge IGCSE™ and O Level Computer Science

Answers to Student’s Book


Exam-style questions and sample answers have been written by the authors. References to
assessment and/or assessment preparation are the publisher’s interpretation of the syllabus
requirements and may not fully reflect the approach of Cambridge Assessment International
Education. Cambridge International recommends that teachers consider using a range of teaching
and learning resources in preparing learners for assessment, based on their own professional
judgement of their students’ needs.
Cambridge Assessment International Education bears no responsibility for the example answers to
questions taken from its past question papers which are contained in this publication.
The questions, example answers, marks awarded and/or comments that appear in this digital
material were written by the author(s). In examination, the way marks would be awarded to
answers like these may be different.

10 Boolean logic
Answers to activities
10.1

(A AND
(A OR B)
A AND NOT A NOT B) OR NOT (A
A B A OR B AND (NOT
NOT B AND B (NOT A AND B)
(A AND B))
AND B)
0 0 0 0 0 0 1 0
0 1 0 1 1 1 1 1
1 0 1 0 1 1 1 1
1 1 0 0 0 1 0 0

10.2
1 a A B X
0 0 1
0 1 0
1 0 0
1 1 1

b A B X
0 0 0
0 1 0
1 0 0
1 1 0

Cambridge IGCSE and O Level Computer Science Teacher's Guide 1


© David Watson and Helen Williams 2021
Answers to Student’s Book

c A B C X
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 1

d A B C X
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 0

e A B C X
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 1

2 a (A AND B) XOR (B NOR C)


b (A NAND C NAND A) NOR (B NOR C)

Cambridge IGCSE and O Level Computer Science Teacher's Guide 2


© David Watson and Helen Williams 2021
Answers to Student’s Book

10.3

1 i A B C X
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 0

ii

2 i A B C X
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 0

Cambridge IGCSE and O Level Computer Science Teacher's Guide 3


© David Watson and Helen Williams 2021
Answers to Student’s Book

ii

3 i (NOT A AND NOT B) OR (A AND B)


[or (a.b) + (a.b)]
ii

4 a (NOT A AND NOT B AND NOT C) OR (A AND NOT B AND NOT C) OR


(A AND NOT B AND C)
or
(a.b.c) + (a. b.c) + (a.b.c)
b (NOT A AND NOT B AND C) OR (NOT A AND B AND NOT C) OR (A AND NOT B
AND NOT C) OR (A AND NOT B AND C)
or
(a.b.c) + (a.b.c) + (a.b.c) + (a.b.c)

Cambridge IGCSE and O Level Computer Science Teacher's Guide 4


© David Watson and Helen Williams 2021
Answers to Student’s Book

5 a (NOT A AND NOT B AND NOT C) OR (NOT A AND NOT B AND C) OR (A AND
NOT B AND NOT C) OR (A AND NOT B AND C)
or
(a.b.c) + (a.b.c) + (a.b.c) + (a.b.c)
b NOT A AND A AND (NOT A AND NOT B)
A B C X
NOT B NOT B OR (A AND NOT B)
0 0 0 1 1 0 1
0 0 1 1 1 0 1
0 1 0 0 0 0 0
0 1 1 0 0 0 0
1 0 0 1 0 1 1
1 0 1 1 0 1 1
1 1 0 0 0 0 0
1 1 1 0 0 0 0

Cambridge IGCSE and O Level Computer Science Teacher's Guide 5


© David Watson and Helen Williams 2021
Answers to Student’s Book

10.4
1 a

A B X
0 0 0
0 1 1
1 0 1
1 1 1

A B C Y
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 0

Cambridge IGCSE and O Level Computer Science Teacher's Guide 6


© David Watson and Helen Williams 2021
Answers to Student’s Book

K L M T
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1

A B C X
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 0

Cambridge IGCSE and O Level Computer Science Teacher's Guide 7


© David Watson and Helen Williams 2021
Answers to Student’s Book

A B C R
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1

2 Logic statement: (NOT R) OR (C AND NOT T) OR (R AND NOT T)


Logic circuit:

Truth table:

R T C X
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 0

Cambridge IGCSE and O Level Computer Science Teacher's Guide 8


© David Watson and Helen Williams 2021
Answers to Student’s Book

3 Logic statement: (G AND NOT W) OR (NOT G AND R) OR (W AND R)


Logic circuit:

Truth table:

G R W S

0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1

Cambridge IGCSE and O Level Computer Science Teacher's Guide 9


© David Watson and Helen Williams 2021
Answers to Student’s Book

4 i Truth table:

E P W S

0 0 0 0

0 0 1 1

0 1 0 1

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 0

1 1 1 1

ii Logic statement: (NOT E AND P) OR (NOT P AND W) OR (P AND W)


iii Logic circuit:

5 A AND NOT A AND (A AND B) OR (NOT


A B X
B NOT B A AND NOT B)

0 0 0 1 1 1

0 1 0 0 0 0

1 0 0 0 0 0

1 1 1 0 1 1

Cambridge IGCSE and O Level Computer Science Teacher's Guide 10


© David Watson and Helen Williams 2021
Answers to Student’s Book

Answers to exam-style questions


Answers to question 5 in this section are example answers for past paper questions. The details of
the relevant past paper can be found with the corresponding exam-style question in the Student’s Book.
1 a i NOT A AND B
(a.b)
ii

b i (A AND (A NAND B)) NOR (B NOR C)


ii A B C X
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1

2 a (A AND B) NOR (NOT A AND NOT B)


b

c A B C X
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 0

Cambridge IGCSE and O Level Computer Science Teacher's Guide 11


© David Watson and Helen Williams 2021
Answers to Student’s Book

3 a (S AND T) OR (NOT S AND NOT V) OR (T AND NOT V)

b S T V X
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1

4 a (NOT X AND NOT Y) OR (X AND NOT Y)


or in alternative notation:
x.y + x.y
b

Cambridge IGCSE and O Level Computer Science Teacher's Guide 12


© David Watson and Helen Williams 2021
Answers to Student’s Book

5 a A B OUTPUT
0 0 0
0 1 1
1 0 1
1 1 1

b XOR gate
c (T AND NOT P) OR (S AND NOT T)

d Two from:
• continuous measurements taken
• won't forget to take readings
• more accurate readings
• safer since no human in contact with potentially dangerous process
• cost saving since no need to pay any wages

Cambridge IGCSE and O Level Computer Science Teacher's Guide 13


© David Watson and Helen Williams 2021
Answers to Student’s Book

6 a (NOT S AND T) OR (S AND P) OR (NOT T AND NOT P)


b

c S T P X
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 1

Cambridge IGCSE and O Level Computer Science Teacher's Guide 14


© David Watson and Helen Williams 2021
Answers to Student’s Book

Chapter 10 Extension Answers


Task 1
A B F X
0 0 1 0
0 1 1 0
1 0 1 0
1 1 0 1
This truth table is the same as an AND gate.
A B F G X
0 0 1 1 0
0 1 1 0 1
1 0 0 1 1
1 1 0 0 1
This truth table is the same as an OR gate.
A F X
0 0 1
1 1 0
This truth table is the same as a NOT gate.
Task 2
1 We simply replace each AND, OR and NOT gate with the NAND gate equivalents given in
Figure 10.34:

To confirm we can write down both truth tables. First, for the circuit shown in the question:

A B C J K X
0 0 0 0 1 1
0 0 1 0 0 0
0 1 0 0 1 1
0 1 1 0 0 0
1 0 0 0 1 1
1 0 1 0 0 0
1 1 0 1 1 1
1 1 1 1 0 1

Cambridge IGCSE and O Level Computer Science Teacher's Guide 15


© David Watson and Helen Williams 2021
Answers to Student’s Book

Then, for the equivalent NAND circuit we have drawn:

A B C F G H J X
0 0 0 0 1 1 0 1
0 0 1 0 0 1 1 0
0 1 0 0 1 1 0 1
0 1 1 0 0 1 1 0
1 0 0 0 1 1 0 1
1 0 1 0 0 1 1 0
1 1 0 1 1 0 0 1
1 1 1 1 0 0 1 1
The yellow highlights show the inputs and outputs for both circuits, which are the same, and
therefore the circuits are equivalent.
2 One way to approach this is to first consider the XOR truth table, which is what we want
to achieve:

A B X
0 0 0
0 1 1
1 0 1
1 1 0
We can see how close this is to an OR gate truth table:

A B F G X
0 0 1 1 0
0 1 1 0 1
1 0 0 1 1
1 1 0 0 1
The only row we need to amend from the OR gate truth table is the final one. We require F and
G to both be 1 so that X = F NAND G is 0 on that final row, i.e.:

A B F G X
0 0 1 1 0
0 1 1 0 1
1 0 0 1 1
1 1 1 1 0

Cambridge IGCSE and O Level Computer Science Teacher's Guide 16


© David Watson and Helen Williams 2021
Answers to Student’s Book

It is only when A and B are both 1 that we want to amend the OR gate circuit. A NAND could
be used to do this, because a NAND gate has the property that only when both inputs are 1 is
the output different:

A B A NAND B
0 0 1
0 1 1
1 0 1
1 1 0
How can we combine A NAND B with A in order that F has the values we require?
By combining gates as follows:

A B A NAND B F
0 0 1 1
0 1 1 1
1 0 1 0
1 1 0 0
It can be seen that F = A NAND (A NAND B).
We can use the same approach for G, but this time considering the input B:

A B A NAND B F = A NAND (A NAND B) G = B NAND (A NAND B)


0 0 1 1 1
0 1 1 1 0
1 0 1 0 1
1 1 0 1 1
We now have the values of F and G that will ensure the output X (which is still
X = F NAND G as per the OR circuit) behaves like an XOR gate:

A B F = A NAND (A NAND B) G = B NAND (A NAND B) X


0 0 1 1 0
0 1 1 0 1
1 0 0 1 1
1 1 1 1 0
Let’s draw the circuit:

Cambridge IGCSE and O Level Computer Science Teacher's Guide 17


© David Watson and Helen Williams 2021
Answers to Student’s Book

Task 3
A B F G H X
0 0 1 1 0 1
0 1 1 0 1 0
1 0 0 1 1 0
1 1 0 0 1 0
By considering only the inputs A, B and the output X we can see this is the inverse of an OR gate,
which is called an NOR gate.

Cambridge IGCSE and O Level Computer Science Teacher's Guide 18


© David Watson and Helen Williams 2021

You might also like