AQA - A Level Computer Science Sample Chapter
AQA - A Level Computer Science Sample Chapter
A-level
Computer
Science
Bob Reeves
Tackle the new A-level specifications confidently with the leading names in
Computing education. Our highly experienced and respected authors and speakers
will help you find the right path to student success, with textbooks, digital teaching
and learning resources and CPD for you to plan and deliver outstanding lessons.
The following Student’s book has been selected for AQA’s official approval process
AQA A-level Computer Science Bob Reeves 9781471839511 April 2015 £29.99
To pre-order or sign up for Inspection Copies visit
www.hoddereducation.co.uk/ALevelComputing/AQA
Also available:
AQA A-level Computer Science Dynamic Learning
AQA
Dynamic Learning is an online subscription solution used in thousands of schools. It A-level
supports teachers and students with high quality content and unique tools. Dynamic Includes AS and A-level
Learning incorporates Teaching and Learning resources, Whiteboard and Student Computer
eTextbook elements that all work together to give you the ultimate classroom and Science
homework resource. Bob Reeves
Written by a leading computing author the Teaching and Learning resource for AQA
A-level Computer Science features:
• Support tasks, both written and practical, the latter supported with sample scripts AQA
A-level
dynamic-learning
Coming soon
• My Revision Notes: AQA A-level Computer Science (publishing January 2016)
• Philip Allan Updates CPD courses to help you teach the new AQA specifications
Sign up to our regular computing updates at www.hoddereducation.co.uk
Contents
Contents
Section One Fundamentals of Programming
Chapter 1 Programming Basics
Chapter 2 Programming Concepts
Chapter 3 Basic Operations in Programming Languages
Chapter 4 Subroutines, Local and Global Variables
Chapter 5 Structured programming
Chapter 6 Object-Oriented Programming Concepts
Chapters contain:
Specification coverage Key points
Taken directly from the All of the main points for each Diagrams and images
specification, it shows which chapter are summarised. These The book uses diagrams and
elements of AS and A-level are are particularly useful as a images wherever possible to aid
covered within each chapter. revision aid. understanding of the key points.
Introduction
This is a concise introduction to
set the scene.
Introduction
6
Learning objectives
Matched to the specification,
these summarise what you will
learn by the end of the chapter. Key words
All of the key words are
identified with concise
The main text definitions. These form a
This contains detailed glossary, which is useful
definitions, explanations and for revision and to check
examples. understanding.
Acknowledgements
Introduction
Dave Fogg for producing the code examples used.
Paul Varey for his initial proofread.
Dedicated to Eli Reeves
Code example
Where relevant there are examples of
Research/study questions
pseudo-code or actual code to demonstrate
These questions go beyond
particular concepts. Code examples in this
the specification and provide a
book are mainly written using the VB.NET
further challenge designed to
framework. VB Express 10.0 has been used
encourage you to “read around
as this is available as a free download.
the subject” or develop your
The code can also be migrated into other
skills and knowledge further.
versions of VB.
Tasks
These are activities designed to
test your understanding of the
contents of the chapter. These
may be written exercises or Practice questions
computer tasks. These are provided for each
section and are contextualised
so that they match the style of
AQA questions.
28 Number Systems
Specification coverage
3.5.2.1 Number base
3.5.3.1 Bits and Bytes
3.5.3.2 Units
Introduction
Computers process data in digital form. Essentially this means that
they use microprocessors, also referred to as ‘chips’, to control them.
A chip is a small piece of silicon implanted with millions of electronic
circuits. The chip receives pulses of electricity that are passed around
these microscopic circuits in a way that allows computers to create text,
numbers, sounds and graphics. All of this is achieved by manipulating
binary data. In this chapter you will discover how binary is used and how
it relates to other number bases such as decimal and hexadecimal.
Learning objectives
In this chapter you will learn:
• The function of bits and bytes and how they are combined to form
larger units
• How number bases work including binary, decimal and hexadecimal
• How to convert binary to decimal and vice versa
• How to convert binary to hexadecimal and vice versa
• How to convert decimal to hexadecimal and vice versa
●● The bit
8
It all comes down to the ‘bit’. A bit is a binary digit. The chip can only handle
Keywords electricity in a relatively simple way – either electricity is flowing, or it is not.
Bit: a single digit from a binary This is often referred to as two ‘states’. The processor can recognise whether it
number - either a zero or a one.
is receiving an ‘off’ signal or an ‘on’ signal. This is handled as a zero (0) for off
and a one (1) for on. A binary digit therefore is either a 0 or a 1.
The processor now needs to convert these 0s and 1s into something useful
for the user. Although it might be difficult to comprehend, everything you
use your computer for is made up of 0s and 1s. To help you understand
this, think of Morse code.
Morse code only uses two signals – a dot and a dash. These two states can
Key Points be used to create every letter in the alphabet. It achieves this by stringing
The byte
• Computers process data in dots and dashes together in different combinations. Perhaps the most
digital form, that is, as series well-known piece of Morse code is ‘dot dot dot – dash dash dash – dot
of 0s and 1s.
dot dot’. ‘Dot dot dot’ is S and ‘dash dash dash’ is O. Therefore we get SOS
• 0s and 1s are called binary which stands for Save Our Souls – the standard distress call for ships in
digits or bits. trouble.
• Bits are grouped together to
create bytes. Computers string zeros and ones together in a similar way to represent text,
• Bytes are grouped together to numbers, sound, video and everything else we use our computers for. The
create kilobytes, megabytes, really clever thing about computers is their ability to string zeros and ones
gigabytes and terabytes. together at very high speed. The ‘clock speed’ of your computer indicates the
speed at which the signals are sent around the processor. A clock speed of
2 GHz means that it will receive 2000 million of these on/off pulses per second.
●● The byte
The first hint most students get of the nature of the byte is when they
Keywords begin to measure the size of memory or disk space in terms of megabtyes,
Byte: a group of bits, typically gigabytes and terabytes.
8, used to represent a single
character. A single byte is a string of eight bits. Eight is a useful number of bits as
it creates enough permutations (or combinations) of zeros and ones to
represent every character on your keyboard. Follow this through:
● With one bit we have two permutations: 0 and 1.
● With two bits we have four permutations: 00, 01, 10 and 11. This could
be represented as 2 2 or 2 × 2. As we increase the number of bits, we
increase the number of permutations by the power of two.
● Three bits would give us 2 3 which is 2 × 2 × 2 = 8 permutations. 9
● Four bits would give us 24 permutations which is 2 × 2 × 2 × 2 = 16
permutations.
If we stop at four you can see that 4 bits would give us enough
permutations to represent 16 different letters of the alphabet, 16 different
numbers, 16 different colours or 16 different sounds. If we move on to 8
bits, we get 28 which is 256 permutations. Therefore, 8 bits is enough to
represent every letter in the alphabet and every keyboard character with a
few to spare. 8 bits is referred to as a byte, which represents one character.
The basic fact here is that the more bits you use, the greater the range of
numbers, characters, sounds or colours that can be created. Taking numbers
as an example, as we have seen, 8 bits would be enough to represent 256
different numbers (0 – 255). As the number of bits increases, the range of
numbers increases rapidly. For example 216 would give 65 536 permutations,
224 would give approximately 16 million and 232 would give over 4 billion.
●● Units
Larger combinations of bytes are used to measure the capacity of memory and
Keywords storage devices. The size of the units can be referred to either using binary or
Unit: The grouping together decimal prefixes. For example, in decimal, the term kilo is commonly used to
of bits of bytes to form larger indicate a unit that is 1000 times larger than a single unit. So the correct term
blocks of measurement e.g. KG, would be kilobyte (K). In binary, the correct term is actually kibibyte (Ki) with
MB.
1024 bytes being the nearest binary equivalent to 1000.
It is common practice to show the size of the numbers using superscript
values. For example 210 Ki indicates binary (base 2) to the power of ten,
which is 1024 bytes. 103 K indicates decimal base ten to the power of three,
which is 1000 bytes.
Common units are shown below using both binary and decimal prefixes:
Binary Decimal
kibibyte Ki 210 kilobyte K 10 3
mebibyte Mi 2 20 megabyte M 10 6
gibibyte Gi 2 30 gigabyte G 10 9
tebibyte Ti 2 40 terabyte T 1012
●● Number bases
A number base indicates how many different digits are available when
Keywords using a particular number system. For example, decimal is number base
Number base: The amount 10 which means that it uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 and
28 Number Systems
of digits available within a binary is number base 2 which means that it uses two digits: 0 and
particular number system, e.g. 1. Different number bases are needed for different purposes. Humans
base 10 for decimal, base 2 for use number base 10, whereas computers use binary as this represents
binary. digital data.
The number base determines how many digits are needed to represent a
number. For example, the number 98 in decimal (base 10) requires two
digits. The binary (base 2) equivalent is 1100010 which requires seven
digits. As a consequence of this there are many occasions in computing
when very long binary codes are needed. To solve this problem, other
10
number bases can be used, which require fewer digits to represent
numbers. For example, some aspects of computing involve number base 16
which is referred to as ‘hexadecimal’.
The accepted method for representing different number bases (in textbooks
and exam questions) is to show the number with the base in subscript. For
example:
● 4310 is decimal
● 10112 is binary
● 2A716 is hexadecimal.
Key Points Hexadecimal
There is scope for confusion here as humans rarely use letters as numbers.
Also, the numbers in hex may convert to different numbers in decimal. For
example, the number 16 in decimal is the equivalent of the number 10 (one
zero) in hex.
above, but working the other way. For example, to convert the number 98:
● Write down the power of 2 sequence. (Eight bits are used here but you
will notice that you only need seven for this example.)
MSB LSB
128 64 32 16 8 4 2 1
64 + 32 + 2 = 98
4 Ancient number systems did not use zero. Explain how a number
system can work without a zero.
5 Apart from the ones you have already looked at, what other number
bases are used, or have been used throughout history.
6 Why do we use base 12 and base 60 for telling the time rather than base 10?
7 Find a simulation of a binary watch online. See if you can learn to tell
the time as quickly in binary as you can using decimals.
8 Identify a situation where it would be appropriate to use the following
units of measurement:
14
a) Exabyte
b) Zettabyte
c) Yottabyte
Practice Questions
1. Convert the binary data 10110111 00111110 into hexadecimal.
2.Give one example of where hexadecimal numbers are used, and explain
why they are used here rather than binary numbers.
3. What is the decimal equivalent of the hexadecimal number E4?
The Publishers would like to thank the following for permission to reproduce copyright material:
P.7 © carloscastilla – Fotolia.
Every effort has been made to trace all copyright holders, but if any have been inadvertently overlooked
the Publishers will be pleased to make the necessary arrangements at the first opportunity.
Although every effort has been made to ensure that website addresses are correct at time of going to
press, Hodder Education cannot be held responsible for the content of any website mentioned. It is
sometimes possible to find a relocated web page by typing in the address of the home page for a website
in the URL window of your browser.
Hachette UK’s policy is to use papers that are natural, renewable and recyclable products and made from
wood grown in sustainable forests. The logging and manufacturing processes are expected to conform to
the environmental regulations of the country of origin.
Orders: please contact Bookpoint Ltd, 130 Milton Park, Abingdon, Oxon OX14 4SB. Telephone: (44)
01235 827720. Fax: (44) 01235 400454. Lines are open 9.00–17.00, Monday to Saturday, with a 24-
hour message answering service. Visit our website at www.hoddereducation.co.uk
© Bob Reeves 2015
First published in 2015 by
Hodder Education
An Hachette UK Company,
338 Euston Road
London NW1 3BH
Impression number 5 4 3 2 1
Year 2019 2018 2017 2016 2015
All rights reserved. Apart from any use permitted under UK copyright law, no part of this publication
may be reproduced or transmitted in any form or by any means, electronic or mechanical, including
photocopying and recording, or held within any information storage and retrieval system, without
permission in writing from the publisher or under licence from the Copyright Licensing Agency Limited.
Further details of such licences (for reprographic reproduction) may be obtained from the Copyright
Licensing Agency Limited, Saffron House, 6–10 Kirby Street, London EC1N 8TS.
Cover photo © LaCozza – Fotolia
Typeset in 11/13 pt Berkely Oldstyle
ISBN 978 1 447 183951 1
AQA
A-level Computer
Science Includes AS and A-level
This sample chapter is from AQA A-level Computer Science, the new textbook for
the AQA AS and A-level specifications, for first teaching from September 2015.
This title has been selected for AQA’s official approval process.
AQA A-level Computer Science gives students the confidence to think creatively
and progress through the AQA AS and A-level specifications. Detailed coverage of
the specifications enriches their understanding of the fundamental principles of
computing, whilst a range of activities help to develop the programming and
computational thinking skills they need for success at A-level and beyond.
• Helps build a thorough understanding of the fundamental principles examined in
the AQA A-level Computer Science specifications (including programming,
algorithms, data structures and representation, systems, databases and
networks, uses and consequences)
• Provides clear coverage and progression through the AS and A-level
specifications, written by a leading computer science author
• Prepares students to tackle the various demands of the course, from
programming and theoretical assessments to the investigative project at A-level
• Helps students develop key skills through frequent coding and exam practice, in
order that they can demonstrate and apply their knowledge of the principles of
computer science, and design, program and evaluate problem-solving computer
systems.
Dynamic Learning
Textbook subject to
AQA A-level Computer Science Dynamic Learning change based on Ofqual
feedback
This book is fully supported by Dynamic Learning – the online
subscription service that helps make teaching and learning easier.
Dynamic Learning provides unique tools and content for:
●● front-of-class teaching
●● streamlining planning and sharing lessons
●● focused and flexible assessment preparation
●● independent, flexible student study