0% found this document useful (0 votes)
17 views52 pages

(Ebook) Programming and Mathematical Thinking: A Gentle Introduction To Discrete Math Featuring Python by Allan M. Stavely ISBN 9781938159008, 9781938159015, 1938159004, 1938159012 Download

The document is an introduction to the ebook 'Programming and Mathematical Thinking: A Gentle Introduction to Discrete Math Featuring Python' by Allan M. Stavely, which focuses on the intersection of programming and discrete mathematics. It emphasizes the importance of mathematical thinking in programming and uses Python as a teaching tool for various mathematical concepts. The book is designed for readers with some programming experience and aims to enhance their understanding of discrete mathematics in a programming context.

Uploaded by

conmyryleslz
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
0% found this document useful (0 votes)
17 views52 pages

(Ebook) Programming and Mathematical Thinking: A Gentle Introduction To Discrete Math Featuring Python by Allan M. Stavely ISBN 9781938159008, 9781938159015, 1938159004, 1938159012 Download

The document is an introduction to the ebook 'Programming and Mathematical Thinking: A Gentle Introduction to Discrete Math Featuring Python' by Allan M. Stavely, which focuses on the intersection of programming and discrete mathematics. It emphasizes the importance of mathematical thinking in programming and uses Python as a teaching tool for various mathematical concepts. The book is designed for readers with some programming experience and aims to enhance their understanding of discrete mathematics in a programming context.

Uploaded by

conmyryleslz
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/ 52

(Ebook) Programming and Mathematical Thinking: A

Gentle Introduction to Discrete Math Featuring


Python by Allan M. Stavely ISBN 9781938159008,
9781938159015, 1938159004, 1938159012 download
https://ebooknice.com/product/programming-and-mathematical-
thinking-a-gentle-introduction-to-discrete-math-featuring-
python-49183594

Explore and download more ebooks at ebooknice.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles, James


ISBN 9781459699816, 9781743365571, 9781925268492, 1459699815,
1743365578, 1925268497

https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT II Success)


by Peterson's ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018

(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master the SAT
Subject Test: Math Levels 1 & 2) by Arco ISBN 9780768923049,
0768923042

https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-
arco-master-the-sat-subject-test-math-levels-1-2-2326094

(Ebook) Matematik 5000+ Kurs 2c Lärobok by Lena Alfredsson, Hans


Heikne, Sanna Bodemyr ISBN 9789127456600, 9127456609

https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312
(Ebook) Cambridge IGCSE and O Level History Workbook 2C - Depth Study:
the United States, 1919-41 2nd Edition by Benjamin Harrison ISBN
9781398375147, 9781398375048, 1398375144, 1398375047

https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044

(Ebook) Programming For Computations - Python: A Gentle Introduction


To Numerical Simulations With Python 3.6 by Svein Linge, Hans Petter
Langtangen ISBN 9783030168766, 9783030168773, 303016876X, 3030168778

https://ebooknice.com/product/programming-for-computations-python-a-
gentle-introduction-to-numerical-simulations-with-python-3-6-10556354

(Ebook) Math 2001: Introduction to Discrete Mathematics by Agnès


Beaudry

https://ebooknice.com/product/math-2001-introduction-to-discrete-
mathematics-10544556

(Ebook) Python Programming: An Introduction to Computer Science by


John M. Zelle

https://ebooknice.com/product/python-programming-an-introduction-to-
computer-science-7343896

(Ebook) Python for the Life Sciences: A Gentle Introduction to Python


for Life Scientists by Alexander Lancaster, Gordon Webster ISBN
9781484245231, 1484245237

https://ebooknice.com/product/python-for-the-life-sciences-a-gentle-
introduction-to-python-for-life-scientists-43425662
Programming and Mathematical
Thinking
A Gentle Introduction to Discrete Math
Featuring Python

Allan M. Stavely

The New Mexico Tech Press


Socorro, New Mexico, USA
Programming and Mathematical Thinking
A Gentle Introduction to Discrete Math Featuring Python
Allan M. Stavely

Copyright © 2014 Allan M. Stavely

First Edition

Content of this book available under the Creative Commons Attribution-Noncommercial-ShareAlike License. See
http://creativecommons.org/licenses/by-nc-sa/4.0/ for details.

Publisher's Cataloguing-in-Publication Data

Stavely, Allan M
Programming and mathematical thinking: a gentle introduction to discrete
math featuring Python / Allan M. Stavely.
xii, 246 p.: ill. ; 28 cm
ISBN 978-1-938159-00-8 (pbk.) — 978-1-938159-01-5 (ebook)
1. Computer science — Mathematics. 2. Mathematics — Discrete
Mathematics. 3. Python (Computer program language).

QA 76.9 .M35 .S79 2014


004-dc22

OCLC Number: 863653804

Published by The New Mexico Tech Press, a New Mexico nonprofit corporation

The New Mexico Tech Press


Socorro, New Mexico, USA
http://press.nmt.edu
Once more, to my parents, Earl and Ann

i
ii
Table of Contents
Preface ........................................................................................................ vii
1. Introduction ............................................................................................. 1
1.1. Programs, data, and mathematical objects ..................................... 1
1.2. A first look at Python .................................................................... 3
1.3. A little mathematical terminology ................................................ 10
2. An overview of Python ........................................................................... 17
2.1. Introduction ................................................................................. 17
2.2. Values, types, and names ............................................................. 18
2.3. Integers ........................................................................................ 19
2.4. Floating-point numbers ................................................................ 23
2.5. Strings .......................................................................................... 25
3. Python programs .................................................................................... 29
3.1. Statements ................................................................................... 29
3.2. Conditionals ................................................................................ 31
3.3. Iterations ..................................................................................... 35
4. Python functions ..................................................................................... 41
4.1. Function definitions ..................................................................... 41
4.2. Recursive functions ...................................................................... 43
4.3. Functions as values ...................................................................... 45
4.4. Lambda expressions ..................................................................... 48
5. Tuples ..................................................................................................... 51
5.1. Ordered pairs and n-tuples .......................................................... 51
5.2. Tuples in Python .......................................................................... 52
5.3. Files and databases ...................................................................... 54
6. Sequences ............................................................................................... 57
6.1. Properties of sequences ................................................................ 57
6.2. Monoids ...................................................................................... 59
6.3. Sequences in Python ..................................................................... 64
6.4. Higher-order sequence functions .................................................. 67
6.5. Comprehensions .......................................................................... 73
6.6. Parallel processing ....................................................................... 74
7. Streams ................................................................................................... 83
7.1. Dynamically-generated sequences ................................................ 83
7.2. Generator functions ..................................................................... 85

iii
Programming and Mathematical Thinking

7.3. Endless streams ............................................................................ 90


7.4. Concatenation of streams ............................................................ 92
7.5. Programming with streams .......................................................... 95
7.6. Distributed processing ............................................................... 103
8. Sets ....................................................................................................... 107
8.1. Mathematical sets ...................................................................... 107
8.2. Sets in Python ............................................................................ 110
8.3. A case study: finding students for jobs ....................................... 114
8.4. Flat files, sets, and tuples ........................................................... 118
8.5. Other representations of sets ...................................................... 123
9. Mappings ............................................................................................. 127
9.1. Mathematical mappings ............................................................. 127
9.2. Python dictionaries .................................................................... 131
9.3. A case study: finding given words in a file of text ...................... 135
9.4. Dictionary or function? .............................................................. 140
9.5. Multisets .................................................................................... 145
10. Relations ............................................................................................ 153
10.1. Mathematical terminology and notation .................................. 153
10.2. Representations in programs .................................................... 156
10.3. Graphs ..................................................................................... 159
10.4. Paths and transitive closure ...................................................... 164
10.5. Relational database operations ................................................ 167
11. Objects ............................................................................................... 175
11.1. Objects in programs ................................................................. 175
11.2. Defining classes ........................................................................ 177
11.3. Inheritance and the hierarchy of classes ................................... 180
11.4. Object-oriented programming .................................................. 184
11.5. A case study: moving averages ................................................. 185
11.6. Recursively-defined objects: trees ............................................. 194
11.7. State machines ......................................................................... 201
12. Larger programs ................................................................................. 213
12.1. Sharing tune lists ...................................................................... 213
12.2. Biological surveys .................................................................... 218
12.3. Note cards for writers .............................................................. 227
Afterword ................................................................................................. 233
Solutions to selected exercises ................................................................... 235
Index ........................................................................................................ 241

iv
List of Examples
1.1. Finding a name ...................................................................................... 4
1.2. Finding an email address ....................................................................... 7
1.3. Average of a collection of observations .................................................. 8
6.1. Finding a name again, in functional style ............................................. 71
6.2. Average of observations again, in functional style ................................ 72
7.1. Combinations using a generator function ............................................ 89
8.1. Finding job candidates using set operations ....................................... 117
8.2. Job candidates again, with different input files .................................. 122
9.1. Finding given words in a document ................................................... 139
9.2. A memoized function: the nth Fibonacci number ................................ 144
9.3. Number of students in each major field ............................................. 149
10.1. Distances using symmetry and reflexivity ......................................... 159
11.1. The MovingAverage class .................................................................. 191
11.2. The MovingAverage class, version 2 ................................................. 193
11.3. The Pushbutton class ....................................................................... 204
11.4. A state machine for finding fields in a string .................................... 206
11.5. Code that uses a FieldsStateMachine ............................................. 207
11.6. A state machine for finding fields, version 2 .................................... 209

v
vi
Preface
My mission in this book is to encourage programmers to think mathematically
as they develop programs.

This idea is nothing new to programmers in science and engineering fields,


because much of their work is inherently based on numerical mathematics
and the mathematics of real numbers. However, there is more to mathematics
than numbers.

Some of the mathematics that is most relevant to programming is known as


“discrete mathematics”. This is the mathematics of discrete elements, such as
symbols, character strings, truth values, and “objects” (to use a programming
term) that are collections of properties. Discrete mathematics is concerned
with such elements; collections of them, such as sets and sequences; and
connections among elements, in structures such as mappings and relations.
In many ways discrete mathematics is more relevant to programming than
numerical mathematics is: not just to particular kinds of programming, but
to all programming.

Many experienced programmers approach the design of a program by


describing its input, output, and internal data objects in the vocabulary of
discrete mathematics: sets, sequences, mappings, relations, and so on. This is
a useful habit for us, as programmers, to cultivate. It can help to clarify our
thinking about design problems; in fact, solutions often become obvious. And
we inherit a well-understood vocabulary for specifying and documenting our
programs and for discussing them with other programmers.1

For example, consider this simple programming problem. Suppose that we


are writing software to analyze web pages, and we want some code that will
read two web pages and find all of the URLs that appear in both. Some
programmers might approach the problem like this:

1
This paragraph and the example that follows are adapted from a previous book: Allan M. Stavely,
Toward Zero-Defect Programming (Reading, Mass.: Addison Wesley Longman, 1999), 142–143.

vii
First I'll read the first web page and store all the URLs I find in a list.
Then I'll read the second web page and, every time I find a URL, search
the list for it. But wait: I don't want to include the same URL in my
result more than once. I'll keep a second list of the URLs that I've
already found in both web pages, and search that before I search the
list of URLs from the first web page.

But a programmer who is accustomed to thinking in terms of discrete-


mathematical structures might immediately think of a different approach:

The URLs in a web page are a set. I'll read each web page and build
up the set of URLs in each using set insertion. Then I can get the URLs
common to both web pages by using set intersection.

Either approach will work, but the second is conceptually simpler, and it will
probably be more straightforward to implement. In fact, once the problem is
described in mathematical terms, most of the design work is already done.

That's the kind of thinking that this book promotes.

As a vehicle, I use the programming language Python. It's a clean, modern


language, and it comes with many of the mathematical structures that we will
need: strings, sets, several kinds of sequences, finite mappings (dictionaries,
which are more general than arrays), and functions that are first-class values.
All these are built into the core of the language, not add-ons implemented by
libraries as in many programming languages. Python is easy to get started
with and makes a good first language, far better than C or C++ or Java, in
my opinion. In short, Python is a good language for Getting Things Done with
a minimum of fuss. I use it frequently in my own work, and many readers will
find it sufficient for much or all of their own programming.

Mathematically, I start at a rather elementary level: the book assumes no


mathematical background beyond algebra and logarithms. In a few places I
use examples from elementary calculus, but a reader who has not studied
calculus can skip these examples. I don't assume a previous course in discrete
mathematics; I introduce concepts from discrete mathematics as I go along.
Some of these are simple but powerful concepts that (unfortunately) some

viii
programmers never learn, and we'll see how to use them to create simple and
elegant solutions to programming problems.

For example, one recurring theme in the book is the concept of a monoid. It
turns out that monoids (more than, for example, groups and semigroups) are
ubiquitous in the data types and data structures that programmers use most
often. I emphasize the extent to which all monoids behave alike and how
concepts and algorithms can be transferred from one to another.

I recommend this book for use in a first university-level course, or even an


advanced high-school course, for mathematically-oriented students who have
had some exposure to computers and programming. For students with no
such exposure, the book could be supplemented by an introductory
programming textbook, using either Python or another programming language,
or by additional lecture material or tutorials presenting techniques of
programming. Or the book could be used in a second course that is preceded
by an introductory programming course of the usual kind.

Otherwise, the ideal reader is someone who has had at least some experience
with programming, using either Python or another programming language.
In fact, I hope that some of my readers will be quite experienced programmers
who may never have been through a modern, mathematically-oriented program
of study in computer science. If you are such a person, you'll see many ideas
that will probably be new to you and that will probably improve your
programming.

At the end of most chapters is a set of exercises. Instructors can use these
exercises in laboratory sessions or as homework exercises, and some can be
used as starting points for class discussions. Many instructors will want to
supplement these exercises with their own extended programming assignments.

In a number of places I introduce a topic and then say something like “…


details are beyond the scope of this book.” The book could easily expand to
encompass most of the computer science curriculum, and I had to draw the
line somewhere. I hope that many readers, especially students, will pursue
some of these topics further, perhaps with the aid of their instructors or in
later programming and computer science classes. Some of the topics are

ix
exception handling, parallel computing, distributed computing, various
advanced data structures and algorithms, object-oriented programming, and
state machines.

Similarly, I could have included many more topics in discrete mathematics


than I did, but I had to draw the line somewhere. Some computer scientists
and mathematicians may well disagree with my choices, but I have tried to
include topics that have the most relevance to day-to-day programming. If
you are a computer science student, you will probably go on to study discrete
mathematics in more detail, and I hope that the material in this book will
show you how the mathematics is relevant to your programming work and
motivate you to take your discrete-mathematics classes more seriously.

This book is not designed to be a complete textbook or reference manual for


the Python language. The book will introduce many Python constructs, and
I'll describe them in enough detail that a reader unfamiliar with Python should
be able to understand what's going on. However, I won't attempt to define
these constructs in all their detail or to describe everything that a programmer
can do with them. I'll omit some features of Python entirely: they are more
advanced than we'll need or are otherwise outside the scope of this book.
Here are a few of them:

• some types, such as complex and byte

• some operators and many of the built-in functions and methods

• string formatting and many details of input and output

• the extensive standard library and the many other libraries that are
commonly available

• some statement types, including break and continue, and else-clauses in


while-statements and for-statements

• many variations on function parameters and arguments, including default


values and keyword parameters

• exceptions and exception handling

x
• almost all “special” attributes and methods (those whose names start and
end with a double underbar) that expose internal details of objects

• many variations on class definitions, including multiple inheritance and


decorators

Any programmer who uses Python extensively should learn about all of these
features of the language. I recommend that such a person peruse a
comprehensive Python textbook or reference manual.2

In any case, there is more to Python than I present in this book. So whenever
you think to yourself, “I see I can do x with Python — can I do y too?”, maybe
you can. Again, you can find out in a Python textbook or reference manual.

This book will describe the most modern form of Python, called Python 3. It
may be that the version of Python that you have on your computer is a version
of Python 2, such as Python 2.3 or 2.7. There are only a few differences that
you may see as you use the features of Python mentioned in this book. Here
are the most important differences (for our purposes) between Python 3 and
Python 2.7, the final and most mature version of Python 2:

• In Python 2, print is a statement type and not a function. A print statement


can contain syntax not shown in the examples in this book; however, the
syntax used in the examples — print(e) where e is a single expression —
works in both Python 2 and Python 3.

• Python 2 has a separate “long integer” type that is unbounded in size.


Conversion between plain integers and long integers (when necessary) is
largely invisible to the programmer, but long integers are (by default)
displayed with an “L” at the end. In Python 3, all integers are of the same
type, unbounded in size.

• Integer division produces an integer result in Python 2, not a floating-point


result as in Python 3.

2
As of the time of writing, comprehensive Python documentation, including the official reference
manual, can be found at http://docs.python.org.

xi
• In Python 2, characters in a string are ASCII and not Unicode by default;
there is a separate Unicode type.

Versions of Python earlier than 2.7 have more incompatibilities than these:
check the documentation for the version you use.

In the chapters that follow I usually use the author's “we” for a first-person
pronoun, but I say “I” when I am expressing my personal opinion, speaking
of my own experiences, and so on. And I follow this British punctuation
convention: punctuation is placed inside quotation marks only if it is part of
what is being quoted. Besides being more logical (in my opinion), this treatment
avoids ambiguity. For example, here's how many American style guides tell
you to punctuate:

To add one to i, you would write “i = i + 1.”

Is the “.” part of what you would write, or not? It can make a big difference,
as any programmer knows. There is no ambiguity this way:

To add one to i, you would write “i = i + 1”.

I am grateful to all the friends and colleagues who have given me help,
suggestions, and support in this writing project, most prominently Lisa
Beinhoff, Horst Clausen, Jeff Havlena, Peter Henderson, Daryl Lee, Subhashish
Mazumdar, Angelica Perry, Steve Schaffer, John Shipman, and Steve Simpson.

Finally, I am pleased to acknowledge my debt to a classic textbook: Structure


and Interpretation of Computer Programs (SICP) by Abelson and Sussman.3
I have borrowed a few ideas from it: in particular, for my treatments of higher-
order functions and streams. And I have tried to make my book a showcase
for Python much as SICP was a showcase for the Scheme language. Most
important, I have used SICP as an inspiration, a splendid example of how
programming can be taught when educators take programming seriously.

3
Harold Abelson and Gerald Jay Sussman with Julie Sussman, Structure and Interpretation of Computer
Programs (Cambridge, Mass.: The MIT Press, 1985).

xii
Chapter 1
Introduction
1.1. Programs, data, and mathematical objects
A master programmer learns to think of programs and data at many levels of
detail at different times. Sometimes the appropriate level is bits and bytes and
machine words and machine instructions. Often, though, it is far more
productive to think and work with higher-level data objects and higher-level
program constructs.

Ultimately, at the lowest level, the program code that runs on our computers
is patterns of bits in machine words. In the early days of computing, all
programmers had to work with these machine-level instructions all the time.
Now almost all programmers, almost all the time, use higher-level
programming languages and are far more productive as a result.

Similarly, at the lowest level all data in computers is represented by bits


packaged into bytes and words. Most beginning programmers learn about
these representations, and they should. But they should also learn when to
rise above machine-level representations and think in terms of higher-level
data objects.

The thesis of this book is that, very often, mathematical objects are exactly
the higher-level data objects we want. Some of these mathematical objects are
numbers, but many — the objects of discrete mathematics — are quite different,
as we will see.

So this book will present programming as done at a high level and with a
mathematical slant. Here's how we will view programs and data:

Programs will be text, in a form (which we call “syntax”) that does not look
much like sequences of machine instructions. On the contrary, our programs
will be in a higher-level programming language, whose syntax is designed for

1
Programs, data, and mathematical objects

writing, reading, and understanding by humans. We will not be much


concerned with the correspondence between programming-language constructs
and machine instructions.

The data in our programs will reside in a computer's main storage (which we
often metaphorically call “memory”) that may look like a long sequence of
machine words, but most of the time we will not be concerned with exactly
how our data objects are represented there; the data objects will look like
mathematical objects from our point of view. We assume that the main storage
is quite large, usually large enough for all the data we might want to put into
it, although not infinite in size.

We will assume that what looks simple in a program is also reasonably simple
at the level of bits and bytes and machine instructions. There will be a
straightforward correspondence between the two levels; a computer science
student or master programmer will learn how to construct implementations
of the higher-level constructs from low-level components, but from other
books than this one. We will play fair; we will not present any program
construct that hides lengthy computations or a mass of complexity in its low-
level implementation. Thus we will be able to make occasional statements
about program efficiency that may not be very specific, but that will at least
be meaningful. And you can be assured that the programming techniques that
we present will be reasonable to use in practical programs.

The language of science is mathematics; many scientists, going back to Galileo,


have said so. Equally, the language of computing is mathematics. Computer
science education teaches why and how this is so, and helps students gain
some fluency in the aspects of this language that are most relevant to them.
The current book takes a few steps in these directions by introducing some
of the concepts of discrete mathematics, by showing how useful they can be
in programming, and by encouraging programmers to think mathematically
as they do their work.

2
A first look at Python

1.2. A first look at Python


For the examples in this book, we'll use a particular programming language,
called Python. I chose Python for several reasons. It's a language that's in
common use today for producing many different kinds of software. It's
available for most computers that you're likely to use. And it's a clean and
well-designed language: for the most part, the way you express things in Python
is straightforward, with a minimum of extraneous words and punctuation. I
think you're going to enjoy using Python.

Python falls into several categories of programming language that you might
hear programmers talk about:

• It's a scripting language. This term doesn't have a precise definition, but
generally it means a language that lends itself to writing little programs
called scripts, perhaps using the kinds of commands that you might type
into a command-line window on a typical computer system. For example,
some scripts are programs that someone writes on the spur of the moment
to do simple manipulations on files or to extract data from them. Some
scripts control other programs, and system administrators often use scripting
languages to combine different functions of a computer's operating system
to perform a task. We'll see examples of Python scripts shortly. (Other
scripting languages that you might encounter are Perl and Ruby.)

• It's an object-oriented language. Object orientation is a very important


concept in programming languages. It's a rather complex concept, though,
so we'll wait to discuss it until Chapter 11. For now, let's just say that if
you're going to be working on a programming project of any size, you'll
need to know about object-oriented programming and you'll probably be
using it. (Other object-oriented languages are Java and C++.)

• It's a very high-level language, or at least it has been called that. This is
another concept that doesn't have a precise definition, but in the case of
Python it means that mathematical objects are built into the core of the
language, more so than in most other programming languages. Furthermore,
in many cases we'll be able to work with these objects in notation that

3
A first look at Python

resembles mathematical notation. We'll be exploiting these aspects of Python


throughout the book.

Depending on how you use it, Python can be a language of any of these kinds
or all of them at once.

Let's look at a few simple Python programs, to give you some idea of what
Python looks like.

The first program is the kind of very short script that a Python programmer
might write to use just once and then discard. Let's say that you have just
attended a lecture, and you met someone named John, but you can't remember
his last name. Fortunately, the lecturer has a file of the names of all the
attendees and has made that file available to you. Let's say that you have put
that file on your computer and called it “names”. There are several hundred
names in the file, so you'd like to have the computer do the searching for you.
Example 1.1 shows a Python script that will display all the lines of the file
that start with the letters “John”.

Example 1.1. Finding a name


file = open("names")
for line in file:
if line.startswith("John"):
print(line)

You may be able to guess (and guess correctly) what most of the parts of this
script do, especially if you have done any programming in another
programming language, but I'll explain the script a line at a time. Let's not
bother with the fine points, such as what the different punctuation marks
mean in Python; you'll learn all that later. For now, I'll just explain each line
in very general terms.
file = open("names")

4
A first look at Python

This line performs an operation called “opening” a file on our computer. It's
a rather complicated sequence of operations, but the general idea is this: get
a file named “names” from our computer's file system and make it available
for our program to read from. We give the name file to the result.

Here and in the other examples in this book, we won't worry about what
might happen if the open operation fails: for example, if there is no file with
the given name, or if the file can't be read for some reason. Serious Python
programmers need to learn about the features of Python that are used for
handling situations like these, and need to include code for handling
exceptional situations in most programs that do serious work.1 In a simple
one-time script like this one, though, a Python programmer probably wouldn't
bother. In any case, we'll omit all such code in our examples, simply because
that code would only distract from the points that we are trying to make.
for line in file:

This means, “For each line in file, do what comes next.” More precisely, it
means this: take each line of file, one at a time. Each time, give that line the
name line, and then do the lines of the program that come next, the lines that
are indented.
if line.startswith("John"):

This means what it appears to mean: if line starts with the letters “John”, do
what comes next.
print(line)

Since the line of the file starts with “John”, it's one that we want to see, and
this is what displays the line. On most computers, we can run the program in
a window on our computer's screen, and print will display its results in that
window.

1
The term for such code is “exception handling”, in case you want to look up the topic in Python
documentation. Handling exceptions properly can be complicated, sometimes involving difficult design
decisions, which is why we choose to treat the topic as beyond the scope of the current book.

5
A first look at Python

If you run the program, here's what you might see (depending, of course, on
what is in the file names).
John Atencio

John Atkins

Johnson Cummings

John Davis

John Hammerstein

And so on. This is pretty much as you might expect, although there may be
a couple of surprises here. Why is this output double-spaced? Well, it turns
out that each line of the file ends with a “new line” character, and the print
operation adds another. (As you learn more details of Python, you'll probably
learn how to make output like this come out single-spaced if that's what you'd
prefer.) And why is there one person here with the first name “Johnson”
instead of “John”? That shouldn't be a surprise, since our simple little program
doesn't really find first names in a line: it just looks for lines in which the first
four letters are “John”. Anyway, this output is probably good enough for a
script that you're only going to use once, especially if it reminds you that the
person you were thinking of is John Davis.

Now let's say that you'd like to get in touch with John Davis. Your luck
continues: the lecturer has provided another file containing the names and
email addresses of all the attendees. Each line of the file contains a person's
name and that person's email address, separated by a comma.

Suppose you transfer that file to your computer and give it the name “emails”.
Then Example 1.2 shows a Python script that will find and display John
Davis's email address if it's in the file.

6
Exploring the Variety of Random
Documents with Different Content
THE ADVENTURES OF ROBINSON CRUSOE.
70 illustrations.
ALICE’S ADVENTURES IN WONDERLAND.
42 illustrations.
THROUGH THE LOOKING GLASS AND
WHAT ALICE FOUND THERE. 50
illustrations.
BUNYAN’S PILGRIM’S PROGRESS. 46
illustrations.
A CHILD’S STORY OF THE BIBLE. 72
illustrations.
A CHILD’S LIFE OF CHRIST. 49 illustrations.
ÆSOP’S FABLES. 62 illustrations.
SWISS FAMILY ROBINSON. 50 illustrations.
EXPLORATION AND ADVENTURE IN
AFRICA. 80 illustrations.
GULLIVER’S TRAVELS. 50 illustrations.
MOTHER GOOSE’S RHYMES, JINGLES AND
FAIRY TALES. 234 illustrations.
THE STORY OF THE FROZEN SEAS. 70
illustrations.
WOOD’S NATURAL HISTORY. 80
illustrations.
BLACK BEAUTY. By Anna Sewell. 50
illustrations.
ARABIAN NIGHTS’ ENTERTAINMENTS. 130
illustrations.
ANDERSEN’S FAIRY TALES. 75 illustrations.
GRIMM’S FAIRY TALES. 50 Illustrations.
FLOWER FABLES. By Louisa M. Alcott. 50
illustrations.
AUNT MARTHA’S CORNER CUPBOARD. By
Mary and Elizabeth Kirby. 54
illustrations.
WATER BABIES. By Charles Kingsley. 84
illustrations.
UNCLE TOM’S CABIN. 90 illustrations.
TALES FROM SHAKESPEARE. By Charles
and Mary Lamb. 65 illustrations.
ADVENTURES IN TOYLAND. 70 illustrations.
ADVENTURES OF A BROWNIE. 18
illustrations.
MIXED PICKLES. 31 illustrations.
LITTLE LAME PRINCE. By Miss Mulock. 24
illustrations.
THE SLEEPY KING. 77 illustrations.
RIP VAN WINKLE. By Washington Irving. 46
illustrations.
A CHILD’S GARDEN OF VERSES. By Robert
Louis Stevenson. 100 illustrations.
ANIMAL STORIES FOR LITTLE PEOPLE. 50
illustrations.
ALTEMUS’
Stories from History Series
A series of stories from history which every
boy and girl should know. No library
is complete without these valuable
contributions to juvenile literature.
Profusely illustrated. Bound in cloth with
illuminated covers, 50 cents each.
ROMULUS, THE FOUNDER OF ROME. By
Jacob Abbott, 49 illustrations.
CYRUS THE GREAT, THE FOUNDER OF THE
PERSIAN EMPIRE. By Jacob Abbott.
40 illustrations.
DARIUS THE GREAT, KING OF THE MEDES
AND PERSIANS. By Jacob Abbott. 34
illustrations.
XERXES THE GREAT, KING OF PERSIA. By
Jacob Abbott. 39 illustrations.
ALEXANDER THE GREAT, KING OF
MACEDON. By Jacob Abbott. 51
illustrations.
PYRRHUS, KING OF EPIRUS. By Jacob
Abbott. 45 illustrations.
HANNIBAL, THE CARTHAGINIAN. By Jacob
Abbott. 37 illustrations.
JULIUS CÆSAR, THE ROMAN CONQUEROR.
By Jacob Abbott. 44 illustrations.
DICKENS’ CHILD’S HISTORY OF ENGLAND.
80 illustrations.
ALFRED THE GREAT, OF ENGLAND. By
Jacob Abbott. 40 illustrations.
WILLIAM THE CONQUEROR, OF ENGLAND.
By Jacob Abbott. 43 illustrations.
CHRISTOPHER COLUMBUS AND THE
DISCOVERY OF AMERICA. 70
illustrations.
HERNANDO CORTEZ, THE CONQUEROR OF
MEXICO. By Jacob Abbott. 30
illustrations.
QUEEN ELIZABETH, OF ENGLAND. By Jacob
Abbott. 49 illustrations.
MARY, QUEEN OF SCOTS. By Jacob Abbott.
45 illustrations.
GRANDFATHER’S CHAIR. By Nathaniel
Hawthorne. 68 illustrations.
KING CHARLES THE FIRST, OF ENGLAND.
By Jacob Abbott. 41 illustrations.
KING CHARLES THE SECOND, OF
ENGLAND. By Jacob Abbott. 28
illustrations.
MADAME ROLAND, A HEROINE OF THE
FRENCH REVOLUTION. By Jacob
Abbott. 42 illustrations.
MARIE ANTOINETTE, QUEEN OF FRANCE.
By John S. C. Abbott. 41 illustrations.
JOSEPHINE, EMPRESS OF FRANCE. By
Jacob Abbott. 40 illustrations.
BATTLES OF THE WAR FOR
INDEPENDENCE, By Prescott
Holmes. 70 illustrations.
MILITARY HEROES OF THE UNITED
STATES. 60 illustrations.
HEROES OF THE UNITED STATES NAVY. 60
illustrations.
LIVES OF THE PRESIDENTS OF THE
UNITED STATES. With portraits and
illustrations.
BATTLES OF THE WAR FOR THE UNION. By
Prescott Holmes. 80 illustrations.
YOUNG PEOPLE’S HISTORY OF THE WAR
WITH SPAIN. 50 illustrations.

Altemus’ Illustrated
Mother Goose Series
A series of entirely new editions of the most
popular books for young people.
Handsomely printed from large, clear
type, on choice paper; each volume
containing about one hundred
illustrations. Half vellum, with
illuminated sides (6⅞ × 8¾ inches).
Price, 50 cents each.
Aladdin; or, The Wonderful Lamp.—Our Animal
Friends.—Beauty and the Beast.—Bird
Stories for Little People.—Cinderella;
or, The Little Glass Slipper.—The
House that Jack Built.—Jack and the
Bean-Stalk.—Jack the Giant-Killer.—
Little Red Riding Hood.—Puss in Boots.
—The Sleeping Beauty.—Who Killed
Cock Robin?

Altemus’ Illustrated
Little Men and Women Series
A new series for young people, by the best
known English and American
authors. Profusely illustrated, and
with handsome and appropriate
bindings. Cloth, 12mo. Price, 50 cts.
each.

Black Beauty. By Anna Sewell.


Hiawatha. By Henry W. Longfellow.
Alice in Wonderland and Through the Looking Glass. By
Lewis Carroll.
Paul and Virginia. By Sainte Pierre.
Galopoff, the Talking Pony. By Tudor Jenks.
Gypsy, the Talking Pony. By Tudor Jenks.
Caps and Capers. By Gabrielle E. Jackson.
Doughnuts and Diplomas. By Gabrielle E. Jackson.
For Prey and Spoils. By Frederick A. Ober.
Tommy Foster’s Adventures. By Frederick A. Ober.
Tales from Shakespeare. By Charles and Mary Lamb.
A Little Rough Rider. By Tudor Jenks.
Another Year with Denise and Ned Toodles. By Gabrielle E.
Jackson.
Poor Boys’ Chances. By John Habberton.
Sea Kings and Naval Heroes. By Hartwell James.
Polly Perkins’s Adventures. By E. Louise Liddell.
Folly in Fairyland. By Carolyn Wells.
Folly in the Forest. By Carolyn Wells.
The Boy Geologist. By Prof. E. J. Houston.
Helen’s Babies. By John Habberton.

Altemus’ Illustrated
Wee Books for Wee Folks
Filled with charming stories, beautifully
illustrated with pictures in colors and
black and white. Daintily, yet durably
bound. Price, 50 cents each.
Nursery Tales.—Nursery Rhymes.—The Story
of Peter Rabbit.—The Foolish Fox.—
Three Little Pigs.—The Robber Kitten.

Children’s Gift Series


A new series of the most famous children’s
classics, in new and attractive
bindings with full page illustrations in
color and black and white. Cloth, 4to,
75 cents each.
Alice’s Adventures in Wonderland.—Through
the Looking Glass and What Alice Found
There.—A Child’s Garden of Verses.—-
Mother Goose’s Rhymes, Jingles and
Fairy Tales.—Swiss Family Robinson.—
The Adventures of Robinson Crusoe.—
Grimm’s Fairy Tales.—Andersen’s Fairy
Tales.—Bible Pictures and Stories.—
Animal Stories for Little People.

One-Syllable Series
For Young Readers
Embracing popular works arranged for the
young folks in words of one syllable.
With numerous illustrations by the
best artists. Handsomely bound, with
illuminated covers. Price, 50 cents
each.
Æsop’s Fables.—A Child’s Life of Christ.—The
Adventures of Robinson Crusoe.—
Bunyan’s Pilgrim’s Progress.—Swiss
Family Robinson.—Gulliver’s Travels.—
A Child’s Story of the Old Testament.—
A Child’s Story of the New Testament.—
Bible Stories for Little Children.—The
Story of Jesus.

Altemus’ Illustrated
Dainty Series of Choice Gift Books
Bound in half-white vellum, illuminated sides,
unique designs in gold and colors, with
numerous half-tone illustrations. Price, 50
cents each.

The Silver Buckle. By M. Nataline Crumpton.


Charles Dickens’ Children Stories.
The Children’s Shakespeare.
Young Robin Hood. By G. Manville Fenn.
Honor Bright. By Mary C. Rowsell.
The Voyage of the Mary Adair. By Frances E. Crompton.
The Kingfisher’s Egg. By L. T. Meade.
Tattine. By Ruth Ogden.
The Doings of a Dear Little Couple. By Mary D. Brine.
Our Soldier Boy. By G. Manville Fenn.
The Little Skipper. By G. Manville Fenn.
Little Gervaise and Other Stories.
The Christmas Fairy. By John Strange Winter.
Molly the Drummer Boy. By Harriet T. Comstock.
How a “Dear Little Couple” Went Abroad. By Mary D. Brine.
The Rose-Carnation. By Frances E. Crompton.
Mother’s Little Man. By Mary D. Brine.
Little Swan Maidens. By Frances E. Crompton.
Little Lady Val. By Evelyn Everett Green.
A Young Hero. By G. Manville Fenn.
Queen of the Day. By L. T. Meade.
That Little French Baby. By John Strange Winter.
The Powder Monkey. By G. Manville Fenn.
The Doll that Talked. By Tudor Jenks.
What Charlie Found to Do. By Amanda M. Douglas.

Altemus’
Young Folks Puzzle Pictures’ Series
A new series for young people, including
numerous Puzzle Pictures by the best
artists. Full cloth, illuminated cover design.
Price, 50 cents each.

Mother Goose’s Puzzle Pictures.


The Tale of Peter Rabbit, with Puzzle Pictures.
Animal Tales, with Puzzle Pictures.
The Night Before Christmas, with Puzzle Pictures.
Dog Tales, Cat Tales and Other Tales, with Puzzle Pictures.
Altemus’ Illustrated
Mother Stories Series
An entirely new series, including the best stories
that mothers can tell their children.
Handsomely printed and profusely
illustrated. Ornamental cloth. Price, 50
cents each.

Mother Stories. 89 illustrations.


Mother Nursery Rhymes and Tales. 135 illustrations.
Mother Fairy Tales. 117 illustrations.
Mother Nature Stories. 97 illustrations.
Mother Stories from the Old Testament. 45 illustrations.
Mother Stories from the New Testament. 45 illustrations.
Mother Bedtime Stories. 86 illustrations.
Mother Animal Stories. 92 illustrations.
Mother Bird Stories. 131 illustrations.
Mother Santa Claus Stories. 91 illustrations.

The Motor Boat Club Series


By H. IRVING HANCOCK
The keynote of these books is manliness. The stories
are wonderfully entertaining, and they are at the same
time sound and wholesome. No boy will willingly lay down
an unfinished book in this series.

1 THE MOTOR BOAT CLUB OF THE


KENNEBEC; Or, The Secret of
Smugglers’ Island.
2 THE MOTOR BOAT CLUB AT NANTUCKET;
Or, The Mystery of the Dunstan Heir.
3 THE MOTOR BOAT CLUB OFF LONG
ISLAND; Or, A Daring Marine Game
at Racing Speed.
4 THE MOTOR BOAT CLUB AND THE
WIRELESS; Or, The Dot, Dash and
Dare Cruise.
5 THE MOTOR BOAT CLUB IN FLORIDA; Or,
Laying the Ghost of Alligator Swamp.
6 THE MOTOR BOAT CLUB AT THE GOLDEN
GATE; Or, A Thrilling Capture in the
Great Fog.
7 THE MOTOR BOAT CLUB ON THE GREAT
LAKES; Or, The Flying Dutchman of
the Big Fresh Water.
Cloth, Illustrated Price, per Volume, 50c.

The Range and Grange Hustlers


By FRANK GEE PATCHIN
Have you any idea of the excitements, the glories of
life on great ranches in the West? Any bright boy will
“devour” the books of this series, once he has made a
start with the first volume.

1 THE RANGE AND GRANGE HUSTLERS ON


THE RANCH; Or, The Boy Shepherds
of the Great Divide.
2 THE RANGE AND GRANGE HUSTLERS’
GREATEST ROUND-UP; Or, Pitting
Their Wits Against a Packers’
Combine.
3 THE RANGE AND GRANGE HUSTLERS ON
THE PLAINS; Or, Following the Steam
Plows Across the Prairie.
4 THE RANGE AND GRANGE HUSTLERS AT
CHICAGO; Or, The Conspiracy of the
Wheat Pit.
Cloth, Illustrated Price, per Volume, 50c.

Submarine Boys Series


By VICTOR G. DURHAM
1 THE SUBMARINE BOYS ON DUTY; Or, Life
on a Diving Torpedo Boat.
2 THE SUBMARINE BOYS’ TRIAL TRIP; Or,
“Making Good” as Young Experts.
3 THE SUBMARINE BOYS AND THE
MIDDIES; Or, The Prize Detail at
Annapolis.
4 THE SUBMARINE BOYS AND THE SPIES;
Or, Dodging the Sharks of the Deep.
5 THE SUBMARINE BOYS’ LIGHTNING
CRUISE; Or, The Young Kings of the
Deep.
6 THE SUBMARINE BOYS FOR THE FLAG;
Or, Deeding Their Lives to Uncle
Sam.
7 THE SUBMARINE BOYS AND THE
SMUGGLERS; Or, Breaking Up the
New Jersey Customs Frauds.
The Square Dollar Boys Series
By H. IRVING HANCOCK
1 THE SQUARE DOLLAR BOYS WAKE UP;
Or, Fighting the Trolley Franchise
Steal.
2 THE SQUARE DOLLAR BOYS SMASH THE
RING; Or, In the Lists Against the
Crooked Land Deal.

The College Girls Series


By JESSIE GRAHAM FLOWER, A.M.

1 GRACE HARLOWE’S FIRST YEAR AT OVERTON


COLLEGE.
2 GRACE HARLOWE’S SECOND YEAR AT OVERTON
COLLEGE.
3 GRACE HARLOWE’S THIRD YEAR AT OVERTON
COLLEGE.
4 GRACE HARLOWE’S FOURTH YEAR AT OVERTON
COLLEGE.
5 GRACE HARLOWE’S RETURN TO OVERTON CAMPUS.

Dave Darrin Series


By H. IRVING HANCOCK
1 DAVE DARRIN AT VERA CRUZ; Or,
Fighting With the U. S. Navy in
Mexico.
All these books are bound in Cloth and will be sent
postpaid on receipt of only 50 cents each.

Pony Rider Boys Series


By FRANK GEE PATCHIN
These tales may be aptly described the best books for
boys and girls.

1 THE PONY RIDER BOYS IN THE ROCKIES; Or,


The Secret of the Lost Claim.—2 THE PONY
RIDER BOYS IN TEXAS; Or, The Veiled
Riddle of the Plains.—3 THE PONY RIDER
BOYS IN MONTANA; Or, The Mystery of the
Old Custer Trail.—4 THE PONY RIDER BOYS
IN THE OZARKS; Or, The Secret of Ruby
Mountain.—5 THE PONY RIDER BOYS IN
THE ALKALI; Or, Finding a Key to the
Desert Maze.—6 THE PONY RIDER BOYS IN
NEW MEXICO; Or, The End of the Silver
Trail.—7 THE PONY RIDER BOYS IN THE
GRAND CANYON; Or, The Mystery of Bright
Angel Gulch.
Cloth, Illustrated Price, per Volume, 50c.

The Boys of Steel Series


By JAMES R. MEARS
Each book presents vivid picture of this great industry.
Each story is full of adventure and fascination.

1 THE IRON BOYS IN THE MINES; Or, Starting at


the Bottom of the Shaft.—2 THE IRON
BOYS AS FOREMEN; Or, Heading the
Diamond Drill Shift.—3 THE IRON BOYS ON
THE ORE BOATS; Or, Roughing It on the
Great Lakes.—4 THE IRON BOYS IN THE
STEEL MILLS; Or, Beginning Anew in the
Cinder Pits.
Cloth, Illustrated Price, per Volume, 50c.

The Madge Morton Books


By AMY D. V. CHALMERS

1 MADGE MORTON—CAPTAIN OF THE MERRY MAID.


2 MADGE MORTON’S SECRET.
3 MADGE MORTON’S TRUST.
4 MADGE MORTON’S VICTORY.

Cloth, Illustrated Price, per Volume, 50c.

High School Boys Series


By H. IRVING HANCOCK
In this series of bright, crisp books a new note has
been struck.
Boys of every age under sixty will be interested in
these fascinating volumes.

1 THE HIGH SCHOOL FRESHMEN; Or, Dick


& Co.’s First Year Pranks and Sports.
2 THE HIGH SCHOOL PITCHER; Or, Dick &
Co. on the Gridley Diamond.
3 THE HIGH SCHOOL LEFT END; Or, Dick &
Co. Grilling of the Football Gridiron.
4 THE HIGH SCHOOL CAPTAIN OF THE
TEAM; Or, Dick & Co. Leading the
Athletic Vanguard.
Cloth, Illustrated Price, per Volume, 50c.

Grammar School Boys Series


By H. IRVING HANCOCK
This series of stories, based on the actual doings of
grammar school boys, comes near to the heart of the
average American boy.

1 THE GRAMMAR SCHOOL BOYS OF


GRIDLEY; Or, Dick & Co. Start Things
Moving.
2 THE GRAMMAR SCHOOL BOYS
SNOWBOUND; Or, Dick & Co. at
Winter Sports.
3 THE GRAMMAR SCHOOL BOYS IN THE
WOODS; Or, Dick & Co. Trail Fun and
Knowledge.
4 THE GRAMMAR SCHOOL BOYS IN
SUMMER ATHLETICS; Or, Dick & Co.
Make Their Fame Secure.
Cloth, Illustrated Price, per Volume, 50c.

High School Boys’ Vacation Series


By H. IRVING HANCOCK
“Give us more Dick Prescott books!”
This has been the burden of the cry from young
readers of the country over. Almost numberless letters
have been received by the publishers, making this eager
demand; for Dick Prescott, Dave Darrin, Tom Reade, and
the other members of Dick & Co. are the most popular
high school boys in the land. Boys will alternately thrill
and chuckle when reading these splendid narratives.
1 THE HIGH SCHOOL BOYS’ CANOE CLUB;
Or, Dick & Co.’s Rivals on Lake
Pleasant.
2 THE HIGH SCHOOL BOYS IN SUMMER
CAMP; Or, The Dick Prescott Six
Training for the Gridley Eleven.
3 THE HIGH SCHOOL BOYS’ FISHING TRIP;
Or, Dick & Co. in the Wilderness.
4 THE HIGH SCHOOL BOYS’ TRAINING
HIKE; Or, Dick & Co. Making
Themselves “Hard as Nails.”
Cloth, Illustrated Price, per Volume, 50c.

West Point Series


By H. IRVING HANCOCK
The principal characters in these narratives are manly,
young Americans whose doings will inspire all boy
readers.

1 DICK PRESCOTT’S FIRST YEAR AT WEST


POINT; Or, Two Chums in the Cadet
Gray.
2 DICK PRESCOTT’S SECOND YEAR AT
WEST POINT; Or, Finding the Glory
of the Soldier’s Life.
3 DICK PRESCOTT’S THIRD YEAR AT WEST
POINT; Or, Standing Firm for Flag
and Honor.
4 DICK PRESCOTT’S FOURTH YEAR AT
WEST POINT; Or, Ready to Drop the
Gray for Shoulder Straps.
Cloth, Illustrated Price, per Volume, 50c.

Annapolis Series
By H. IRVING HANCOCK
The principal characters in these narratives are manly,
young in these volumes.

1 DAVE DARRIN’S FIRST YEAR AT


ANNAPOLIS; Or, Two Plebe
Midshipmen at the U. S. Naval
Academy.
2 DAVE DARRIN’S SECOND YEAR AT
ANNAPOLIS; Or, Two Midshipmen as
Naval Academy “Youngsters.”
3 DAVE DARRIN’S THIRD YEAR AT
ANNAPOLIS; Or, Leaders of the
Second Class Midshipmen.
4 DAVE DARRIN’S FOURTH YEAR AT
ANNAPOLIS; Or, Headed for
Graduation and the Big Cruise.
Cloth, Illustrated Price, per Volume, 50c.

The Young Engineers Series


By H. IRVING HANCOCK
The heroes of these stories are known to readers of
the High School Boys Series. In this new series Tom
Reade and Harry Hazelton prove worthy of all the
traditions of Dick & Co.

1 THE YOUNG ENGINEERS IN COLORADO;


Or, At Railroad Building in Earnest.
2 THE YOUNG ENGINEERS IN ARIZONA; Or,
Laying Tracks on the “Man-Killer”
Quicksand.
3 THE YOUNG ENGINEERS IN NEVADA; Or,
Seeking Fortune on the Turn of a
Pick.
4 THE YOUNG ENGINEERS IN MEXICO; Or,
Fighting the Mine Swindlers.
Cloth, Illustrated Price, per Volume, 50c.

Boys of the Army Series


By H. IRVING HANCOCK
These books breathe the life and spirit of the United
States Army of to-day, and the life, just as it is, is
described by a master pen.

1 UNCLE SAM’S BOYS IN THE RANKS; Or,


Two Recruits in the United States
Army.
2 UNCLE SAM’S BOYS ON FIELD DUTY; Or,
Winning Corporal’s Chevrons.
3 UNCLE SAM’S BOYS AS SERGEANTS; Or,
Handling Their First Real Commands.
4 UNCLE SAM’S BOYS IN THE PHILIPPINES;
Or, Following the Flag Against the
Moros.
(Other volumes to follow rapidly.)
Cloth, Illustrated Price, per Volume, 50c.

Battleship Boys Series


By FRANK GEE PATCHIN
These stories throb with the life of young Americans
on to-day’s huge drab Dreadnaughts.

1 THE BATTLESHIP BOYS AT SEA; Or, Two


Apprentices in Uncle Sam’s Navy.
2 THE BATTLESHIP BOYS FIRST STEP
UPWARD; Or, Winning Their Grades
as Petty Officers.
3 THE BATTLESHIP BOYS IN FOREIGN
SERVICE; Or, Earning New Ratings in
European Seas.
4 THE BATTLESHIP BOYS IN THE TROPICS;
Or, Upholding the American Flag in a
Honduras Revolution.
(Other volumes to follow rapidly.)
Cloth, Illustrated Price, per Volume, 50c.

The Meadow-Brook Girls Series


By JANET ALDRIDGE
Real live stories pulsing with the vibrant atmosphere of
outdoor life.

1 THE MEADOW-BROOK GIRLS UNDER CANVAS.


2 THE MEADOW-BROOK GIRLS ACROSS COUNTRY.
3 THE MEADOW-BROOK GIRLS AFLOAT.
4 THE MEADOW-BROOK GIRLS IN THE HILLS.
5 THE MEADOW-BROOK GIRLS BY THE SEA.
6 THE MEADOW-BROOK GIRLS ON THE TENNIS
COURTS.

Cloth, Illustrated Price, per Volume, 50c.


The Circus Boys Series
By EDGAR B. P. DARLINGTON
Mr, Darlington’s books breathe forth every phase of an
intensely interesting and exciting life.

1 THE CIRCUS BOYS ON THE FLYING


RINGS; Or, Making the Start in the
Sawdust Life.
2 THE CIRCUS BOYS ACROSS THE
CONTINENT; Or, Winning New
Laurels on the Tanbark.
3 THE CIRCUS BOYS IN DIXIE LAND; Or,
Winning the Plaudits of the Sunny
South.
4 THE CIRCUS BOYS ON THE MISSISSIPPI;
Or, Afloat with the Big Show on the
Big River.
Cloth, Illustrated Price, per Volume, 50c.

The High School Girls Series


By JESSIE GRAHAM FLOWER, A. M.
These breezy stories of the American High School Girl
take the reader fairly by storm.

1 GRACE HARLOWE’S PLEBE YEAR AT HIGH


SCHOOL; Or, The Merry Doings of
the Oakdale Freshman Girls,
2 GRACE HARLOWE’S SOPHOMORE YEAR
AT HIGH SCHOOL; Or, The Record of
the Girl Chums in Work and Athletics.
3 GRACE HARLOWE’S JUNIOR YEAR AT
HIGH SCHOOL; Or, Fast Friends in
the Sororities.
4 GRACE HARLOWE’S SENIOR YEAR AT
HIGH SCHOOL; Or, The Parting of
the Ways.
Cloth, Illustrated Price, per Volume, 50c.

The Automobile Girls Series


By LAURA DENT CRANE
No girl’s library—no family book-case can be
considered at all complete unless it contains these
sparkling twentieth-century books.

1 THE AUTOMOBILE GIRLS AT NEWPORT; Or,


Watching the Summer Parade.—2 THE
AUTOMOBILE GIRLS IN THE BERKSHIRES;
Or, The Ghost of Lost Man’s Trail.—3 THE
AUTOMOBILE GIRLS ALONG THE HUDSON;
Or, Fighting Fire in Sleepy Hollow.—4 THE
AUTOMOBILE GIRLS AT CHICAGO; Or,
Winning Out Against Heavy Odds.—5 THE
AUTOMOBILE GIRLS AT PALM BEACH; Or,
Proving Their Mettle Under Southern Skies
—6 THE AUTOMOBILE GIRLS AT
WASHINGTON; Or, Checkmating the Plots
of Foreign Spies.
Cloth, Illustrated Price, per Volume, 50c.

Transcriber’s Notes:
Obvious punctuation errors repaired.
Page 15, “canot” changed to “cannot” (cannot
think of God)
Page 49, “dressinig” changed to “dressing” (babe
a-dressing)
Page 64, repeated word “been” removed from
text (has been very naughty)
Page 69, “arisinig” changed to “arising” (the maid
arising)
Page 88, “wil” changed to “will” (I will show you
where)
Page 119, “the” changed to “they” (they saw the
angels)
Page 124, “crucifid” changed to “crucified”
(crucified to save men)
Page 145, repeated word “to” removed from text
(Singing to harps of)
Page 148, “prasing” changed to “praising”
(praising him for having)
*** END OF THE PROJECT GUTENBERG EBOOK THE PEEP OF DAY
***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like