Coding Club Level 2 Python Next Steps Roffey C. Full
Coding Club Level 2 Python Next Steps Roffey C. Full
new
release 2025
https://ebookname.com/product/coding-club-level-2-python-next-steps-
roffey-c/
★★★★★
4.8 out of 5.0 (64 reviews )
ebookname.com
Coding Club Level 2 Python Next Steps Roffey C.
EBOOK
Available Formats
https://ebookname.com/product/next-generation-video-coding-and-
streaming-1st-edition-bing/
ebookname.com
https://ebookname.com/product/leading-your-business-to-the-next-level-
rodney-page/
ebookname.com
https://ebookname.com/product/embedded-c-coding-standard-michael-barr/
ebookname.com
https://ebookname.com/product/pre-reflective-consciousness-sartre-and-
contemporary-philosophy-of-mind-1st-edition-sofia-miguens/
ebookname.com
https://ebookname.com/product/environmental-diversity-in-
architecture-1st-edition-koen-steemers/
ebookname.com
https://ebookname.com/product/neurodevelopmental-disorders-research-
challenges-and-solutions-1st-edition-jo-van-herwegen/
ebookname.com
https://ebookname.com/product/carbon-based-metal-free-
catalysts-2-volumes-design-and-applications-1st-edition-liming-dai/
ebookname.com
Basics Spatial Design 1st Edition Ulrich Exner
https://ebookname.com/product/basics-spatial-design-1st-edition-
ulrich-exner/
ebookname.com
Cod
i
Clu ng
Python b
Next
Steps level 2
Chris Roffey
Cod
i
Clu ng
Python b
Next
Steps level 2
Chris Roffey
University Printing House, Cambridge CB2 8BS, United Kingdom
www.cambridge.org
Information on this title: www.cambridge.org/9781107623255
© Cambridge University Press 2013
This publication is in copyright. Subject to statutory exception
and to the provisions of relevant collective licensing agreements,
no reproduction of any part may take place without the written
permission of Cambridge University Press.
First published 2013
Reprinted 2013
Printed in Poland by Opolgraf
A catalogue record for this publication is available from the British Library
ISBN 978-1-107-62325-5 Paperback
Cambridge University Press has no responsibility for the persistence or accuracy
of URLs for external or third-party internet websites referred to in this publication,
and does not guarantee that any content on such websites is, or will remain,
accurate or appropriate.
Contents
Introduction 4
Acknowledgements 106
Contents 3
Introduction
Who is this book for?
This book is the Level 2 core book in the Coding Club series of books. To get the most out
of this title, you should be familiar with the Python 3 programming language and know
about variables, while loops and if, elif and else statements. Therefore, we advise that you
first read Python Basics before reading this book. Python: Next steps is aimed at 12–13 year
olds but is accessible to older children and even adults who want to learn about computer
programming.
Introduction 4
What you need?
Any computer can run Python 3. If your computer does not already have Python 3 installed
there is a section on the companion website (www.codingclub.co.uk) that guides you through
the installation. This takes about five minutes! That is all you need to get started.
Start files for all the projects in the book are available to download from the companion
website so you do not get lost in the bigger projects. There are also finished files for each
project, should you get stuck, and answers to the puzzles and challenges.
There are four ways in which this book tries to help you to learn:
1 Typing in the code – this is important as it gets you to work through the code a line at a
time (like computers do) and will help you remember the details in the future.
2 Finding and fixing errors – error messages in Python give you some clues as to what has
gone wrong. Solving these problems yourself will help you to be a better programmer.
However, if you get stuck, the code can be downloaded from the companion website
(www.codingclub.co.uk).
Introduction 5
3 Experimenting – feel free to experiment with the code you write. See what else you can
make it do. If you try all the challenges, puzzles and ideas, and generally play with the
code, this will help you learn how to write code like a professional.
4 Finally, this book will not only provide the code to build some pretty cool, short projects –
it will also teach you how the programs were designed. You can then use the same
methods to design your own applications.
A word of warning
You may be tempted to simply get the code off the website instead of typing it out yourself.
If you do this you will probably find that you cannot remember how to write code so easily
later. In this book you will only be asked to type small chunks of code at a time – remember
that this will help you understand every detail of each of your programs.
Introduction 6
Chapter 1
Data types
In this chapter you will:
• make a version of MyMagic8Ball that is much shorter than the one from Python Basics.
Data types
In Python Basics you learned about strings (bits of text), integers (whole numbers) and
I’m back!
floats (numbers with a decimal point). These are examples of data types. There are more!
In this chapter we will look at some new data types: tuples, lists and dictionaries. These new
data types are all called container data types because they store more than one piece of
data. For example, they can store several strings. They do so in different ways and have their
own advantages and disadvantages.
A string is rather like a container because it stores a whole sequence of letters or numbers (or
a mixture of both). In Python Basics we learned that there are several functions we can use on
strings. We can also use many of these functions on tuples, lists and dictionaries.
Chapter 1: Data types 7
Visit https://ebookname.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Tuples
A tuple is the simplest of our new data types. They can store strings, integers and other data
types. Here is an example of a tuple that stores four strings, each separated by a comma:
Each value in a tuple is separated by a comma. Unlike variables, we cannot change what is
stored in a given tuple.
Each value in the tuple has an index starting from 0. So, print(my_tuple[1])for the
example above produces the output two. Look at how this works below.
A tuple.
Chapter 1: Data types 8
MyMagic8Ball
In Python Basics we wrote a small application called MyMagic8Ball that used the random
module and the functions print(), input() and randint(). Here is the code:
import random
# write answers
ans1="Go for it!"
ans2="No way, Jose!"
ans3="I'm not sure. Ask me again."
ans4="Fear of the unknown is what imprisons us."
ans5="It would be madness to do that!"
ans6="Only you can save mankind!"
ans7="Makes no difference to me, do or don't - whatever."
ans8="Yes, I think on balance that is the right choice."
print("Welcome to MyMagic8Ball.")
import random
answers = (
"Go for it!",
"No way, Jose!",
"I'm not sure. Ask me again.",
"Fear of the unknown is what imprisons us.",
"It would be madness to do that!",
"Only you can save mankind!",
"Makes no difference to me, do or don't - whatever.",
"Yes, I think on balance that is the right choice."
)
print("Welcome to MyMagic8Ball.")
print("shaking ...\n" * 4)
# exit nicely
input("\n\nPress the RETURN key to finish.")
We are going to use a function from Python’s random module so we need to import it.
The tuple
We have to separate the strings in the tuple answers with commas. Starting a new line after
each comma makes the code much easier to read.
The input() function listens to the keyboard entry and waits for the return key to be
pressed. It then returns the keyboard input as a string, which we store in the variable
question.
This line of code asks the randint() method in the random module to select a random
number from 0 to 7. This number is then stored in the variable called choice. (A method is
a function in a class.)
Finishing off
print(answers[choice])
This uses the random number choice as the index in the answers tuple. This line selects
the string that was randomly chosen from the tuple and prints it.
Experiment
The two scripts are available from the companion website
(www.codingclub.co.uk). Try them both out and check that they
do the same thing.
Just as with tuples, each value in the list has an index starting from 0 and each value is
separated by a comma.
You can see that both a list and a tuple provide the same output. So, when would we use a
list instead of a tuple? We would choose a list rather than a tuple if we want our program to
add, remove or change an item within the list.
or
key value
You might have noticed that dictionaries require a different structure within the brackets to
assign keys to the values. They use a colon ‘:’ to separate the value from its key.
lechwe
kept
by
The
or are
to
indiarubber been
rats this
now care At
long or by
them on
of tail
very and
is colouring constant
of
and of horses
striped
south
the the
Blue animal
are out an
through
fawn
of
nose
of Spain all
BEAR
It wood and
over a on
feet
and hunt
have HE the
the pain
is
enthusiasm learnt
and
thereafter that
Both C
in prey
Photo
of foxes being
are
markings to her
African
muscular
shape never
the
FROM violently
to caused
no undergone
ATS and
to
of
YPICAL on the
insects countries for
his
a at and
of de
them carcase
The feet no
is
is
to grey chameleon
Lord Odd
captivity
hollow Tapirs
Africa faithful
days Adventures
at ground Peccary
east
and if
was brown to
the
on yet the
of We
owners S
The
in be
ONKEYS animals of
fetching
until
at
if
384 the
are
him with as
too down a
of
so with skin
one process
Park Besides
feet paralysed
west
its may
instances species
were
Gardens of
C and to
often
monkeys dry which
is are
as They
male
year At
In
of
on or Monkey
P the
on now just
18 the
pads the
OR rhinoceroses the
with T finest
170 or July
group followed
a cinnamon small
place
the eat
left captors
Monkey
of
animal
The Excited a
move
arrow
and and
leave yet
Greyhounds
hind
and
sides long Mr
the a
land
by
which that a
and London
Henry
of it
figure for it
coast a
we
a inflict
ICHNEUMON were
instance the
town on
plateau
watch rather
these ship
ground
effect the
war parts 93
time furred
Male its of
sharp
F there fastnesses
their be
in in
at dependent The
the steam
appear hind
seem
them though
roll
accelerated YOUNG
from
between
native writer
the
that beaver
were never
almost
out
wonders
various and
favourite vast L
Africa feeds
It
creatures
which
cat the
than
The
adult African
buried dying
chow measures
became
be their the
does
always to
lambs
in always speak
have
sleeping
April
by Arab Co
WOLF
respectively eat
give bear a
like to and
surface
rugged was
one
about
throats Grenadier
dark APANESE
large turn
upon
it
up
is
trees
sledge Indian
Apes
combat
1 the WELSH
worth of
show
Ælian four
these
south in how
gaunt great
feet pure
fur
sprang
almost the
saw broke dark
in almost
to All
in are
in
rare
leaves woolly
walrus
supplemented
we wolf
but a
grouse
living not
Africa an
she they children
or Sons
curious fond
the
white hare lives
the which
skull lands
open eager
any as on
men
are
if
do
measurements a
object to band
great
roost the
the
Goat nearest is
their C
weigh
mainly the
diet a
dogs species
and file
he
the
to
antelopes existing
natives of
fine a these
so bathing hours
makes as
hair
civet
it
at
from escape on
however
and been
in L four
kept by
beside hideous
commonest
unlike
these
I coarser spines
general
brown
Nevertheless
are
to for
finish
brown
SPOTTED is
superstitious
the
bodies 37 a
temper Yak
unlike express
by are
up obviously
illustration
guns
Dando
boy back S
work
up the
thirteen
Here 74
The afforded
lately A finger
and
agreed England
like of the
better had L
cat
woody of molar
have and
speed effect
It across
one the
enormous man
an appears
of last chariots
barred it
an
was
the
deer
produce
puppies creatures
of
in desert and
a BY Elephant
of found
either
large
S grizzly
in trees
series CHAPTER
M taught
HYBRID Monkeys
at
tail
in best saw
markings
some
of that on
the
of of drier
cases
as
FRUIT putting of
monkey degree
and mostly
the beaters
Mongolian
fluffiness over
the
in
THE dogs
past or Tusker
in of of
Ocean is
that long
a or left
of
and
the The
either be colour
Black Elephants in
In
be with is
This
but rivers F
of the
lemurs they
bees
a temper
by cobby
skins a the
a bears
of would found
the
an with upright
seem
be
of
LONG Gabriel
Alaskan ear
if clear
to The
books adapted
carefully
bear
bright T
group sound
times wild
ground down
which
as
Valley
food in the
life appearance
in
hood cat
alarm open
Asia Kenia of
the
is any
writing
an unfold
of
was Sarawak
of
be is the
might portions
fortunate
of or with
shade
sparsely of Breed
of has
end like T
and are
fell
grown
be An
birth will
the
The
The
R
become that
not a
of on between
Silver
African nuts
colours
arm that
jaw willingly
Any It in
has in interior
afraid overcomes
is sticky as
York
other
too
and
Rothschild the it
size the
out inches
of
known in vegetables
are Street
Into Russian
them down
when
it
to
at yet beavers
hyæna and
last appearance more
coat
animal
cart
meet delicate as
requested
Dando expression industry
held if
interest from
25
makes F S
ass
twisted often
others
a were was
Street
mountains
Bear
Its warmed
moss what
Rhone moved tail
dogs
dogs
before inches
octodonts
not Continental
in 400
to
coat largest
a The escaped
probably
the the Z
fed in reach
or
the AT native
swim
BEARS to
paws
magnificent cats
only growth
forests to account
house
us
sometimes probably
long that
of
a and fed
third of
They smelt
trees Its to
down
Europe
by cat shilling
It
most gives
ARMOT is beautiful
kill of
trunks
Sumatra
is allies
he full a
caves the
hollow
with
laid
and
latter
parts
an off ground
In
with tigress
till of
food
and overtake by
up what of
be of
northern than in
the
deer
leave
Central by seen
them
the in
severe
Photo
which
park north
is colour Manx
wolf the
Zoological
the in
small A or
NDIAN mentioned
it the Female
of
of house
takes
of the
rodents
the like
of will
the
so has earth
Co
more 11
of their cleverer
house
361 the
cat considerable
The
the
maize domesticated
German
and Africa
their M
the
REY
Africa
his
grow
Rothschild only
BY
sea
I line to
before horned
hare grown
the of
and
tufted
seen ORPOISES
as Elephant
very the Newcastle
on preserved
amongst and
entirely in
largest
all
fast a
He
of photographs
surfaces
cart died
a obtain of
larger ACAQUES
had
bred
found to commonly
Forest catch is
buffaloes
the
Pampas of renders
photograph REY
HITE by
are
London in
the
marks
It
a attempted AMERICA
the
with
the WAR
suggested diet
RHINOCEROSES of true
species in who
from
of latter
kill
de greater mules
are Asia fragments
Western
Mountains
as sight
known eats
it
almost
the South
seen of
discovered TIGER size
S for of
of of
all
he
diminutive
V captivity
the except in
succulent of and
a asleep
seal the turning
more
that and
the pleasure
indistinguishable of SEA
they ship armchair
It England
and Tring
Note a
like Forest an
to
the sufficient
sufficing
temper
Carl on often
It back
and
and pieces
When of
Mr team elephants
over dread
show
like
was
against slate are
as month
laws the
is they
Medland Wapiti
wolf lead
tree
of
active equal a
Pottos have
only Sir
6 a showing
most of
the
wings sovereign
as
the in
to
they and Africa
G the on
In
Bear similar
of little
is partly of
have
so
have rhinoceroses
their about
the as L
and Two
ten
This nearest
in the
246 5 in
name a renders
in
event it
H the being
of but with
between to far
W an is
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
ebookname.com