Tiny Python Projects Learn Coding and Testing With Puzzles and Games 1st Edition Ken Youens Clark
Tiny Python Projects Learn Coding and Testing With Puzzles and Games 1st Edition Ken Youens Clark
com
https://ebookmeta.com/product/tiny-python-projects-learn-
coding-and-testing-with-puzzles-and-games-1st-edition-ken-
youens-clark/
OR CLICK HERE
DOWLOAD EBOOK
Ken Youens-Clark
MANNING
KEN YOUENS-CLARK
MANNING
SHELTER ISLAND
For online information and ordering of this and other Manning books,
please visit
20 Baldwin Road
PO Box 761
Email: orders@manning.com
20 Baldwin Road
PO Box 761
ISBN: 9781617297519
brief contents
15
35
55
76
formatting strings
107
128
lists of words
150
10
■
Telephone: Randomly mutating strings
165
11
testing functions
178
12
195
13
207
iii
iv
BRIEF CONTENTS
14
■
Rhymer: Using regular expressions to create
rhyming words
225
15
248
16
of words
268
17
281
18
ASCII values
295
19
311
20
memorable password
331
21
351
22
367
contents
preface
xv
acknowledgments
xvii
xix
xxii
xxiii
Code examples
5
Installing modules
10
Code formatters
10
Code linters
11
11
12
12
13
13
v
vi
CONTENTS
1.1
15
1.2
Comment lines
16
1.3
17
1.4
18
1.5
20
1.6
Understanding $PATH
20
21
1.7
22
1.8
24
1.9
26
1.10
26
1.11
27
28
1.12
Testing hello.py
29
1.13
30
1.14
33
2.1
Getting started
36
37
39
Concatenating strings
41 ■ Variable types
42 ■ Getting
44
String methods
44 ■ String comparisons
45 ■ Conditional
branching
47 ■ String formatting
48 ■ Time to write
49
2.2
Solution
49
2.3
Discussion
50
50 ■ The main()
thing
51
52
2.4
Going further
53
3.1
56
3.2
Writing picnic.py
58
CONTENTS
vii
3.3
Introducing lists
59
list
61 ■ Indexing lists
63 ■ Slicing lists
64 ■ Finding
elements in a list
65
69
Joining a list
70
3.4
70
Time to write
71
3.5
Solution
71
3.6
Discussion
73
73
74
3.7
Going further
75
4.1
Dictionaries
77
Creating a dictionary
78 ■ Accessing dictionary values
80
81
4.2
Writing jump.py
82
4.3
Solution
84
4.4
Discussion
85
85
86 ■ (Not) using
str.replace()
90
4.5
Going further
91
5.1
Reading files
93
5.2
Writing files
97
5.3
Writing howler.py
99
5.4
Solution
101
5.5
Discussion
102
command line
104
104
5.6
Going further
106
viii
CONTENTS
formatting strings
107
6.1
Writing wc.py
109
counting
112
6.2
Solution
114
6.3
Discussion
115
a for loop
115
6.4
Going further
117
7.1
Writing gashlycrumb.py
119
7.2
Solution
122
7.3
Discussion
123
124
125 ■ Dictionary
lookups
126
7.4
Going further
126
8.1
Altering strings
130
131
132
8.2
Solution
133
8.3
Discussion
134
the vowels
135
8.4
149
8.5
Going further
149
lists of words
150
9.1
Writing abuse.py
151
Validating arguments
module
155 ■ Taking
156
CONTENTS
ix
9.2
Solution
157
9.3
Discussion
159
160
with random.seed()
throwaway variables
162
9.4
Going further
163
10.1
Writing telephone.py
167
space
169
Mutating a string
173
10.2
Solution
173
10.3
Discussion
175
Mutating a string
176
10.4
Going further
177
11.1
Writing bottles.py
179
Counting down
181 ■ Writing
186
11.2
Solution
187
11.3
Discussion
189
Counting down
189
The verse() function
191
194
11.4
Going further
194
12.1
Writing ransom.py
197
198 ■ Creating
a new string
198
12.2
Solution
199
12.3
Discussion
200
202
203
204
CONTENTS
12.4
Comparing methods
204
12.5
Going further
205
13.1
Writing twelve_days.py
208
Counting
verses
215 ■ Printing
215
Time to write
215
13.2
Solution
216
13.3
Discussion
218
Making one verse
221
222
13.4
Going further
223
14.1
Writing rhymer.py
227
Breaking a word
229
232 ■ Truthiness
output
238
14.2
Solution
238
14.3
Discussion
240
Stemming a word
expression
program
244 ■ Writing
245
14.4
Going further
246
Writing friar.py
250
251 ■ Shorthand
classes
256
261
15.2
Solution
262
15.3
Discussion
263
266
15.4
Going further
266
CONTENTS
xi
16.1
Writing scrambler.py
269
272
Scrambling a word
16.2
Solution
276
16.3
Discussion
277
279
16.4
Going further
280
17.1
Writing mad.py
282
284
288
289
17.2
Solution
289
17.3
Discussion
290
291
17.4
Going further
293
ASCII values
295
18.1
Writing gematria.py
296
Cleaning a word
ranges
300 ■ Using
functools.reduce
303
304
18.2
Solution
304
18.3
Discussion
305
Writing word2num()
Other documents randomly have
different content
here when he came to make inquiries about the peacock. I made
Baldwin write to Sorley to appoint the thirteenth of November night
as the time to come up. Baldwin showed me the reply, and I knew
that he would be there. I took the stiletto which belonged to Sorley
as I stole it along with the peacock when I left this house. Since it
was his I thought it would make the evidence against him more
certain. I went to Rotherhithe and watched. I saw Sorley go, and
then I went up to Baldwin’s room and stabbed him. It doesn’t matter
how I cajoled him to lie down and rest, and chose my time. I
stabbed him to the heart and that is enough for you to know.”
Again her listeners shivered, for there seemed to be something
terrible about this small frail woman admitting such a dreadful deed
so callously and boldly. She smiled as she saw their feeling. “What a
lot of cowards you men are,” she jeered, “you wouldn’t have acted
so bravely; no, not you.”
“Go on, go on,” said Moon impatiently, “there’s no time to be lost.”
“I have nearly finished,” said Miss Grison tartly, “don’t hurry me,
as you must admit that my confession is interesting. I killed Baldwin
with this,” she added, taking up the stiletto which lay on the table,
“and I took it away, along with the peacock, intending to hide both
in this house. Jotty—ungrateful little reptile that he is—saw me with
these when he came to Thimble Square to tell me of the murder. Ha!
ha! of the murder which I had committed. I wept and wailed, as I
was bound to do, since my dear brother had been murdered by
Sorley. Then came the inquest, and I said nothing, for I waited my
chance. The funeral took place here, and I stayed at Mrs.
Millington’s, she has been a good friend to me. I came to this house
on the day you know of, Mr. Fuller,” she went on, addressing herself
to Alan who nodded in answer, “and while you and Marie were in the
grounds, and this man—if he can be called a man—was asleep, I
placed the peacock in that black-oak cupboard and the stiletto in the
place behind that panel marked with a cross, where I knew Sorley
kept those bits of glass——”
“They are jewels, valuable jewels,” cried her husband irrelevantly.
“Oh, get on with the confession,” said Latimer sharply, for the
prolonged scene was getting on his nerves, “you hid the stiletto and
peacock.”
“Yes,” said Miss Grison snappishly, “and then I waited, guessing
that Sorley would probably seek Mr. Fuller’s help to solve the riddle
of the bird. That was why I introduced the subject of cryptograms
on that day when we were at tea, Mr. Fuller. When I learned that
Jotty had Sorley’s reply to the request of Baldwin I sent him to you
so that it might implicate this beast of a husband of mine. Then
when Jotty told me about the drawing of the peacock, I knew that
Sorley had consulted you, since no drawing had ever been made of
the thing. My trap was set, and by making the matter of the peacock
public, I closed it on the man I hate.”
She shut her mouth with a snap, and idly dug the stiletto into the
table as if she had finished. “What else?” questioned Moon
imperiously.
“Nothing else,” said Miss Grison raising her pale eyes; “you know
all. The trap caught the bird, and my revenge would have been
complete had not this fool learned more than he should have. You, I
mean, you,” said Miss Grison walking slowly towards the Indian,
“why couldn’t you let me have my way?”
“I wanted the jewels,” said Bakche stolidly, and not moving even
when she was face to face with him.
“You shall never have them,” cried Miss Grison unexpectedly, and
before anyone could move she raised her arm. In a moment the
stiletto was in the Indian’s heart, and he fell like a log on the floor.
“Great God!” roared the inspector and sprang forward.
Miss Grison put out her frail arms. “Go on, put the handcuffs
here,” she mocked coolly. “I have settled the beast who balked me
of my revenge!”
“He is quite dead,” said Alan lifting a pale face from an
examination.
“And that beast Sorley lives,” snarled Miss Grison viciously, and
spat at her husband.
CHAPTER XXII
CALM AFTER STORM
THE END
*** END OF THE PROJECT GUTENBERG EBOOK THE PEACOCK OF
JEWELS ***
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
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.