Coding Club Level 3 Python Building Big Apps Spi Ed Roffey C instant download
Coding Club Level 3 Python Building Big Apps Spi Ed Roffey C instant download
Ed Roffey C download
https://ebookbell.com/product/coding-club-level-3-python-
building-big-apps-spi-ed-roffey-c-4678812
https://ebookbell.com/product/coding-club-level-1-python-basics-spi-
ed-roffey-c-4677454
https://ebookbell.com/product/coding-club-level-2-python-next-steps-
spi-ed-roffey-c-4677456
https://ebookbell.com/product/spotlight-on-coding-club-schusterman-
michelle-10094256
https://ebookbell.com/product/coming-in-hot-a-man-of-the-month-club-
novella-a-smalltown-steamy-instalove-romance-elyse-kelly-43719296
Coding Regulation Essays On The Normative Role Of Information
Technology Egbert Dommering
https://ebookbell.com/product/coding-regulation-essays-on-the-
normative-role-of-information-technology-egbert-dommering-46241226
Coding For Beginners In Easy Steps Basic Programming For All Ages Mike
Mcgrath
https://ebookbell.com/product/coding-for-beginners-in-easy-steps-
basic-programming-for-all-ages-mike-mcgrath-46474102
https://ebookbell.com/product/coding-for-beginners-13th-papercut-
limited-47505760
https://ebookbell.com/product/coding-for-pediatrics-2022-a-manual-for-
pediatric-documentation-and-payment-twentyseventh-american-academy-of-
pediatrics-committee-on-coding-and-nomenclature-48844096
https://ebookbell.com/product/coding-shaping-making-experiments-in-
form-and-formmaking-haresh-lalvani-48865738
Cod
i
Clu ng
Python b
Building
BIG Apps level 3
Chris Roffey
Cod
i
Clu ng
Python b
Building
BIG Apps level 3
Chris Roffey
cambridge university press
Cambridge, New York, Melbourne, Madrid, Cape Town,
Singapore, São Paulo, Delhi, Mexico City
www.cambridge.org
Information on this title: www.cambridge.org/9781107666870
A catalogue record for this publication is available from the British Library
Acknowledgements 132
Contents 3
Introduction
Who is this book for?
This book is the Level 3 core book in the Coding Club series. Before reading this, you should
have either read Coding Club, Python: Next Steps or have become familiar with Python 3 and
learned about variables, while loops, lists and tuples. This book is aimed at coders with a
little bit of previous programming experience.
Introduction 4
At this stage in your coding it is important that you are introduced to classes and objects.
This is because you will certainly want to use other people’s classes, and to do this effectively
a little understanding goes a long way. What is special about this book is how the
explanations are rooted in the real world and use analogies that you will understand. The
code is also built so that it mirrors real objects whenever possible. This is so that when you
go on to write your own applications you will be able to imagine how to convert real objects
into coded objects.
So that you do not have to do too much typing and do not get lost in the bigger projects,
there are start files and, if you need them, finished files for all the projects in the book in one
easily downloadable zip file. The website also has answers to the puzzles and challenges to
help you if you get stuck.
1 Typing out the code – this is important as it encourages you to work through the code a
line at a time (like computers do) and will help you to 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 become a better
programmer. To avoid feeling bored and frustrated though, the code can be downloaded
from the companion website www.codingclub.co.uk
3 Experimenting – feel free to experiment with the code you write. See what else you can
make it do. If you try all of the challenges, puzzles and ideas, and generally play with the
code, this will help you learn how to write code like a pro.
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 yourself. If you
do, 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
Can you guess my password?
This book assumes that you have read Coding Club: Python Basics. If you have not, you
should at least understand what variables and functions are and know how to use IDLE in
both interactive mode and script mode. In this first chapter you will recall some of this by
making a very simple application called ‘Guess My Password’. You will then have revised:
• variables
• functions
• while loops
• modules
As in the previous Coding Club books, you will use IDLE, an example of an IDE. You can start by
opening IDLE and then choosing New Window from the File menu. This gets you into IDLE’s script
mode. It is a good idea to now re-arrange the windows so that the interactive mode console and
new window are next to each other and both can be seen at the same time (Figure 1.1).
Python 3.1.3 (r313:86834, Nov 28 2010, 10:01:07) # GuessMyPassword.py is a quick revision application.
[GCC 4.4.5] on linux2
Type "copyright", "credits" or "license()" for more information. import random
==== No Subprocess ====
>>> # Initialise variables:
Hello. response1 = "I am afraid not. Please try again."
response2 = "That is a good password but not my password. Keep guessing."
See if you can guess my password? Abracadabra response3 = "That is not my password. It really is easy to guess my password."
I am afraid not. Please try again. response4 = "Well done! You must work for MI6. Give my regards to James Bond."
MY_PASSWORD = "my password"
What is your next guess?
# Function to find out if the user has guessed correctly:
def is_correct(guess, password):
if guess == password:
guess_correct = True
else:
import random
# Initialise variables:
response1 = "I am afraid not. Please try again."
response2 = "
That is a good password but not my password. Keep guessing."
response3 = "
That is not my password. It really is easy to guess my password."
response4 = "
Well done! You must work for MI6. Give my regards to James Bond."
MY_PASSWORD = "my password"
Comments appear in red in IDLE; these are aimed at humans only and begin with the
hash symbol #.
A module is a collection of useful functions and data in one place. Sometimes we will want
to write our own. Modules have to be imported before they can be used. In this app the
random module is imported so that it can be used later in the program. Variable value
(a string)
n
Variables
i
ase t r y a ga
These are labels we make to allow us to access data. We create a variable by giving it a
name and then assign data to it using the equals operator. Good programmers begin
their variable names with lowercase letters and make them descriptive. The name for
a constant is all in capitals.
Ple
You have just created five string type variables and labeled them response1,
response2, response3, response4 and MY_PASSWORD. response1
MY_PASSWORD is a constant – it does not change.
Functions
Variable name
Figure 1.2 A variable called response1
storing a string.
A function is a piece of code that can be used again and again. You can already
use any of the many functions that are built into Python. You can also make your own.
Functions are created with the def keyword. Here is the code for a function that finds out if
the guess is the correct password.
Add the code from Code Box 1.2 to your GuessMyPassword.py file. The is_correct()
function has to be passed an argument called guess and another argument called
password. The function then compares the two strings. If they are the same, the function
sets the guess_correct variable to True, if not it sets it to False. Finally the function
will return True or False – depending on the state the guess_correct variable is in.
A variable that only stores the values True or False is called a boolean variable.
User input
To get user input from the keyboard we use Python’s input() function which waits for the
user to type some text and press the enter key. If we want to be able to access the input later
we need to assign it to a variable like this:
user_input = input()
Now we are able to access the input, for example, in a print function:
print(user_input)
This program contains
one of those jokes that
We use the input() function three times in this program, in two different ways. are far more fun to tell
Now it is time to finish the program by adding the code from Code Box 1.3 to your than to hear.
GuessMyPassword.py file. As you type, think carefully about what each line does.
THE
EBERS GALLERY
A COLLECTION OF PAINTINGS
ILLUSTRATING THE
ROMANCES OF GEORG EBERS
BY THE FOLLOWING ARTISTS
L. Alma-Tadema, W. A. Beer, W. Gentz, P. Grot-Johann,
H. Kaulbach, Ferd. Keller, O. Knille, F. Simm,
Laura Tadema, E. Teschendorff, P. Thumann.
TWENTY ILLUSTRATIONS
WITH DESCRIPTIVE LETTER-PRESS
Printed from handsome large new type on plate-paper
Photographic Reproduction by Friedrich Bruckmann of Munich
In loose sheets, in cloth covered box, $22.50
One Vol., Folio, bound in half morocco, gilt edges, by Alfred
40.00
Matthews,
One Vol., Folio, superbly bound in full morocco extra, by Alfred
50.00
Matthews,
William S. Gottsberger, Publisher, New York.
THE BRIDE OF THE NILE, a Romance, by Georg Ebers, from the
German by Clara Bell. Authorized edition, in two volumes. Price,
paper covers, $1.00, cloth binding, $1.75 per set.
“This romance has much value, apart from its interest as a narrative. The
learned author, who has made the Land of the Nile an object of special
study and research, throws a clear, steady light on one of those complicated
periods of history when nationality seems submerged in the conflicting
interests of sects and factions. The history of Egypt towards the middle of
the seventh century, A. D., forms a sort of historical whirlpool. The tide of
Moslem invasion and the counter-current of patriotism were temporarily
swayed by the intermingling currents of sectarianism, ecclesiasticism and
individual self-interest.
“All the leading characters are typical of these contending forces, and
also display an unreasoning impulsiveness in both love and hatred,
characteristic of a tropical clime.
“The Egyptian heathen, the Egyptian Christian, the Greek Christian, the
Moslem and Ethiopian show the feelings peculiar to their political
conditions by word and act, thus making their relationship to one another
very distinct, and though not an historical study, at least a study of the
probabilities of that epoch. It is also a reliable picture of the manners,
customs and civilization of a period less generally known than those
remote, and consequently more attractive periods of the building of the
pyramids, and of the Pharoahs.
“The portrayal of individual character and arrangement of incidents are
necessarily secondary to the higher aims of this entertaining and instructive
romance. It is only towards the end of the second volume that the
significance of the title becomes apparent. The ‘Bride’ was a Greek
Christian doomed by the superstitious authorities to be drowned in the Nile
as a sacrifice to appease the anger of the creative powers, supposed to be
withholding the usual overflow of its waters. She escaped her watery fate,
and her rival, an unprincipled heiress, became a voluntary sacrifice through
vanity and despair. This author has already won much renown by previous
romances founded on interesting epochs of Egyptian history.”—Daily Alta,
California.
William S. Gottsberger, Publisher, New York.
THE MARTYR OF GOLGOTHA, by Enrique Perez Escrich, from
the Spanish by Adèle Josephine Godoy, in two volumes. Price, paper
covers, $1.00. Cloth binding, $1.75.
“There must always be some difference of opinion concerning the right
of the romancer to treat of sacred events and to introduce sacred personages
into his story. Some hold that any attempt to embody an idea of our
Saviour’s character, experiences, sayings and teachings in the form of
fiction must have the effect of lowering our imaginative ideal, and
rendering trivial and common-place that which in the real Gospel is
spontaneous, inspired and sublime. But to others an historical novel like the
‘Martyr of Golgotha’ comes like a revelation, opening fresh vistas of
thought, filling out blanks and making clear what had hitherto been vague
and unsatisfactory, quickening insight and sympathy, and actually
heightening the conception of divine traits. The author gives also a wide
survey of the general history of the epoch and shows the various shaping
causes which were influencing the rise and development of the new religion
in Palestine. There is, indeed, an astonishing vitality and movement
throughout the work, and, elaborate though the plot is, with all varieties and
all contrasts of people and conditions, with constant shiftings of the scene,
the story yet moves, and moves the interest of the reader too, along the
rapid current of events towards the powerful culmination. The writer uses
the Catholic traditions, and in many points interprets the story in a way
which differs altogether from that familiar to Protestants: for example,
making Mary Magdalen the same Mary who was the sister of Lazarus and
Martha, and who sat listening at the Saviour’s feet. But in general, although
there is a free use made of Catholic legends and traditions, their effort is
natural and pleasing. The romance shows a degree of a southern fervor
which is foreign to English habit, but the flowery, poetic style—although it
at first repels the reader—is so individual, so much a part of the author, that
it is soon accepted as the naive expression of a mind kindled and carried
away by its subject. Spanish literature has of late given us a variety of
novels and romances, all of which are in their way so good that we must
believe that there is a new generation of writers in Spain who are discarding
the worn-out forms and traditions, and are putting fresh life and energy into
works which will give pleasure to the whole world of readers.”—
Philadelphia American, March 5, 1887.
William S. Gottsberger, Publisher, New York.
“If Italian literature includes any more such unique and charming stories
as this one, it is to be hoped that translators will not fail to discover them to
the American public. The ‘Eleventh Commandment’ deals with a variety of
topics—the social intrigues necessary to bring about preferment in political
life, a communal order, an adventurous unconventional heiress, and her
acquiescent, good-natured uncle, and most cleverly are the various elements
combined, the whole forming an excellent and diverting little story. The
advent of a modern Eve in the masculine paradise (?) established at the
Convent of San Bruno is fraught with weighty consequences, not only to
the individual members of the brotherhood, but to the well-being of the
community itself. The narrative of M’lle Adela’s adventures is blithely told,
and the moral deducible therefrom for men is that, on occasion, flight is the
surest method of combating temptation.”—Art Interchange, New York.
“Very entertaining is the story of ‘The Eleventh Commandment,’
ingeniously conceived and very cleverly executed.”—The Critic, New York.
A WHIMSICAL WOOING.—By Anton Giulio Barrili, from the
Italian by Clara Bell, in one vol. Paper, 25 cts. Cloth, 50 cts.
“If ‘The Eleventh Commandment,’ the previous work of Barrili, was a
good three-act play, ‘A Whimsical Wooing’ is a sparkling comedietta. It is
one situation, a single catastrophe, yet, like a bit of impressionist painting of
the finer sort, it reveals in a flash all the possibilities of the scene. The hero,
Roberto Fenoglio, a man of wealth, position, and accomplishments, finds
himself at the end of his resources for entertainment or interest. Hopelessly
bored, he abandons himself to the drift of chance, and finds himself, in no
longer space of time than from midnight to daylight—where and how, the
reader will thank us for not forestalling his pleasure in finding out for
himself.”—The Nation, New York.
“‘A Whimsical Wooing’ is the richly-expressive title under which ‘Clara
Bell’ introduces a cleverly-narrated episode by Anton Giulio Barrili to
American readers. It is a sketch of Italian life, at once rich and strong, but
nevertheless discreet in sentiment and graceful in diction. It is the old story
of the fallacy of trusting to a proxy in love matters.”—Boston Post.
William S. Gottsberger, Publisher, New York.
GEORG EBERS’
ROMANCES & BIOGRAPHIES
COMPRISING:
AN EGYPTIAN PRINCESS,
TWO VOLUMES
THE BRIDE OF THE NILE,
TWO VOLUMES
SERAPIS,
ONE VOLUME
THE EMPEROR,
TWO VOLUMES
UARDA,
TWO VOLUMES
HOMO SUM,
ONE VOLUME
THE SISTERS,
ONE VOLUME
A QUESTION,
ONE VOLUME
LORENZ ALMA-TADEMA,
ONE VOLUME
RICHARD LEPSIUS,
ONE VOLUME
FOOTNOTES:
[A] Peasants attached to the household, and not to the soil.
[B] Russian cart, consisting of a flat frame-work of bark, between four wheels.
[C] This expression, peculiar to Russia, corresponds to what in Catholic countries
is called: Making a preparatory retreat.
[D] In the Greek Church the staroste acts as church-warden, collector of alms, etc.
[E] Screen, upon which are the images.
[F] Strong Russian phrase, to express great poverty.
[G] Justice of the peace, of the district.
[H] Diminutive of Nicolas.
[I] Yvan.
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
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.
ebookbell.com