100% found this document useful (5 votes)
38 views

[FREE PDF sample] Python for Informatics Exploring Information 1st Edition Dr. Charles R Severance ebooks

Information

Uploaded by

vorrejosepe
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
100% found this document useful (5 votes)
38 views

[FREE PDF sample] Python for Informatics Exploring Information 1st Edition Dr. Charles R Severance ebooks

Information

Uploaded by

vorrejosepe
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/ 58

Download Full ebookname - Read Now at ebookname.

com

Python for Informatics Exploring Information 1st


Edition Dr. Charles R Severance

https://ebookname.com/product/python-for-informatics-
exploring-information-1st-edition-dr-charles-r-severance/

OR CLICK BUTTON

DOWLOAD EBOOK

Discover More Ebook - Explore Now at ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Modernist informatics literature information and the state


1st Edition Purdon

https://ebookname.com/product/modernist-informatics-literature-
information-and-the-state-1st-edition-purdon/

ebookname.com

Exploring with Lewis and Clark Charles Floyd

https://ebookname.com/product/exploring-with-lewis-and-clark-charles-
floyd/

ebookname.com

Programming Like a Pro for Teens 1st Edition Charles R.


Hardnett

https://ebookname.com/product/programming-like-a-pro-for-teens-1st-
edition-charles-r-hardnett/

ebookname.com

Promoting Sustainable Local and Community Economic


Development 1st Edition Roland V. Anglin

https://ebookname.com/product/promoting-sustainable-local-and-
community-economic-development-1st-edition-roland-v-anglin/

ebookname.com
Current Topics in Developmental Biology Vol 71 1st Edition
Gerald P. Schatten (Ed.)

https://ebookname.com/product/current-topics-in-developmental-biology-
vol-71-1st-edition-gerald-p-schatten-ed/

ebookname.com

Insect Symbiosis Contemporary Topics in Entomology 1st


Edition Kostas Bourtzis

https://ebookname.com/product/insect-symbiosis-contemporary-topics-in-
entomology-1st-edition-kostas-bourtzis/

ebookname.com

Construction Law for Design Professionals Construction


Managers and Contractors 1st Edition Justin Sweet

https://ebookname.com/product/construction-law-for-design-
professionals-construction-managers-and-contractors-1st-edition-
justin-sweet/
ebookname.com

Divorcing the Dow Using Revolutionary Market Indicators to


Profit from the Stealth Boom Ahead 1st Edition Jim Troup

https://ebookname.com/product/divorcing-the-dow-using-revolutionary-
market-indicators-to-profit-from-the-stealth-boom-ahead-1st-edition-
jim-troup/
ebookname.com

Hedge Fund Course Wiley Finance 1st Edition Stuart A.


Mccrary

https://ebookname.com/product/hedge-fund-course-wiley-finance-1st-
edition-stuart-a-mccrary/

ebookname.com
Building Research Tools With Google For Dummies 1st
Edition Harold Davis

https://ebookname.com/product/building-research-tools-with-google-for-
dummies-1st-edition-harold-davis/

ebookname.com
Python for Informatics
Exploring Information

Version 0.0.4

Charles Severance
Copyright © 2009, 2010 Charles Severance.

Printing history:

December 2009: Begin to produce Python for Informatics: Exploring Information by re-mixing
Think Python: How to Think Like a Computer Scientist
June 2008: Major revision, changed title to Think Python: How to Think Like a Computer Scientist.
August 2007: Major revision, changed title to How to Think Like a (Python) Programmer.
April 2002: First edition of How to Think Like a Computer Scientist.

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. This
license is available at creativecommons.org/licenses/by-sa/3.0/.

The original form of this book is LATEX source code. Compiling this LATEX source has the effect
of generating a device-independent representation of a textbook, which can be converted to other
formats and printed.

The LATEX source for the Think Python: How to Think Like a Computer Scientist version of this book
is available from http://www.thinkpython.com.

The LATEX source for the Python for Informatics: Exploring Information version of the book is avail-
able from http://source.sakaiproject.org/contrib/csev/trunk/pyinf/.

The cover image shows social connectivity of NSF grant investigators at the University of Michigan
from September 1999 through October 2010 and was provided by Eric Hofer and visualized using
the GUESS software developed by Eytan Adar, both of the University of Michigan. The cover design
is by Terri Geitgey of the University of Michigan Library.
Preface

Python for Informatics: Remixing an Open Book


It is quite natural for academics who are continuously told to “publish or perish” to want
to always create something from scratch that is their own fresh creation. This book is
an experiment in not starting from scratch, but instead “re-mixing” the book titled Think
Python: How to Think Like a Computer Scientist written by Allen B. Downey, Jeff Elkner
and others.
In December of 2009, I was preparing to teach SI502 - Networked Programming at the
University of Michigan for the fifth semester in a row and decided it was time to write a
Python textbook that focused on exploring data instead of understanding algorithms and ab-
stractions. My goal in SI502 is to teach people life-long data handling skills using Python.
Few of my students were planning to be be professional computer programmers. Instead,
they planned be librarians, managers, lawyers, biologists, economists, etc. who happened
to want to skillfully use technology in their chosen field.
I never seemed to find the perfect data-oriented Python book for my course so I set out
to write just such a book. Luckily at a faculty meeting three weeks before I was about to
start my new book from scratch over the holiday break, Dr. Atul Prakash showed me the
Think Python book which he had used to teach his Python course that semester. It is a
well-written Computer Science text with a focus on short, direct explanations and ease of
learning.
The overall book structure has been changed to get to doing data analysis problems as
quickly as possible and have a series of running examples and exercises about data analysis
from the very beginning.
The first 10 chapters are similar to the Think Python book but there have been some
changes. Nearly all number-oriented exercises have been replaced with data-oriented ex-
erises. Topics are presented in the order to needed to build increasingly sophisticated data
analysis solutions. Some topics like try and catch are pulled forward and presented as
part of the chapter on conditionals while other concepts like functions are left until they are
needed to handle program complexity rather introduced as an early lesson in abstraction.
The word “recursion” does not appear in the book at all.
vi Chapter 0. Preface

In chapters 11-14, nearly all of the material is brand new, focusing on real-world uses and
simple examples of Python for data analysis including automating tasks on your computer,
retrieving data across the network, scraping web pages for data, using web services, parsing
XML data, and creating and using databases using Structured Query Language.

The ultimate goal of all of these changes is a shift from a Computer Science to an Infor-
matics focus is to only include topics into a first technology class that can be applied even
if one chooses not to become a professional programmer.

Students who find this book interesting and want to further explore should look at Allen
B. Downey’s Think Python book. Because there is a lot of overlap between the two books,
students will quickly pick up skills in the additional areas of computing in general and
computational thinking that are covered in Think Python. And given that the books have a
similar writing style and at times have identical text and examples, you should be able to
move quickly through Think Python with a minimum of effort.

As the copyright holder of Think Python, Allen has given me permission to change the
book’s license from the GNU Free Documentation License to the more recent Creative
Commons Attribution — Share Alike license. This follows a general shift in open doc-
umentation licenses moving from the GFDL to the CC-BY-SA (i.e. Wikipedia). Using
the CC-BY-SA license maintains the book’s strong copyleft tradition while making it even
more straightforward for new authors to reuse this material as they see fit.

I feel that this book serves an example of why open materials are so important to the future
of education, and want to thank Allen B. Downey and Cambridge University Press for their
forward looking decision to make the book available under an open Copyright. I hope they
are pleased with the results of my efforts and I hope that you the reader are pleased with
our collective efforts.

Charles Severance
www.dr-chuck.com
Ann Arbor, MI, USA
July 25, 2011

Charles Severance is a Clinical Associate Professor at the University of Michigan School


of Information.

Preface for “Think Python”


The strange history of “Think Python”
(Allen B. Downey)

In January 1999 I was preparing to teach an introductory programming class in Java. I had
taught it three times and I was getting frustrated. The failure rate in the class was too high
and, even for students who succeeded, the overall level of achievement was too low.
vii

One of the problems I saw was the books. They were too big, with too much unnecessary
detail about Java, and not enough high-level guidance about how to program. And they all
suffered from the trap door effect: they would start out easy, proceed gradually, and then
somewhere around Chapter 5 the bottom would fall out. The students would get too much
new material, too fast, and I would spend the rest of the semester picking up the pieces.
Two weeks before the first day of classes, I decided to write my own book. My goals were:

• Keep it short. It is better for students to read 10 pages than not read 50 pages.

• Be careful with vocabulary. I tried to minimize the jargon and define each term at
first use.

• Build gradually. To avoid trap doors, I took the most difficult topics and split them
into a series of small steps.

• Focus on programming, not the programming language. I included the minimum


useful subset of Java and left out the rest.

I needed a title, so on a whim I chose How to Think Like a Computer Scientist.


My first version was rough, but it worked. Students did the reading, and they understood
enough that I could spend class time on the hard topics, the interesting topics and (most
important) letting the students practice.
I released the book under the GNU Free Documentation License, which allows users to
copy, modify, and distribute the book.
What happened next is the cool part. Jeff Elkner, a high school teacher in Virginia, adopted
my book and translated it into Python. He sent me a copy of his translation, and I had the
unusual experience of learning Python by reading my own book.
Jeff and I revised the book, incorporated a case study by Chris Meyers, and in 2001 we
released How to Think Like a Computer Scientist: Learning with Python, also under the
GNU Free Documentation License. As Green Tea Press, I published the book and started
selling hard copies through Amazon.com and college book stores. Other books from Green
Tea Press are available at greenteapress.com.
In 2003 I started teaching at Olin College and I got to teach Python for the first time. The
contrast with Java was striking. Students struggled less, learned more, worked on more
interesting projects, and generally had a lot more fun.
Over the last five years I have continued to develop the book, correcting errors, improving
some of the examples and adding material, especially exercises. In 2008 I started work on
a major revision—at the same time, I was contacted by an editor at Cambridge University
Press who was interested in publishing the next edition. Good timing!
I hope you enjoy working with this book, and that it helps you learn to program and think,
at least a little bit, like a computer scientist.
viii Chapter 0. Preface

Acknowledgements for “Think Python”


(Allen B. Downey)
First and most importantly, I thank Jeff Elkner, who translated my Java book into Python,
which got this project started and introduced me to what has turned out to be my favorite
language.
I also thank Chris Meyers, who contributed several sections to How to Think Like a Com-
puter Scientist.
And I thank the Free Software Foundation for developing the GNU Free Documentation
License, which helped make my collaboration with Jeff and Chris possible.
I also thank the editors at Lulu who worked on How to Think Like a Computer Scientist.
I thank all the students who worked with earlier versions of this book and all the contribu-
tors (listed in an Appendix) who sent in corrections and suggestions.
And I thank my wife, Lisa, for her work on this book, and Green Tea Press, and everything
else, too.
Allen B. Downey
Needham MA

Allen Downey is an Associate Professor of Computer Science at the Franklin W. Olin


College of Engineering.
Contents

Preface v

1 Why should you learn to write programs? 1


1.1 Creativity and motivation . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Computer hardware architecture . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Understanding programming . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 The Python programming language . . . . . . . . . . . . . . . . . . . . . 5
1.5 What is a program? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.6 What is debugging? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.7 Building “sentences” in Python . . . . . . . . . . . . . . . . . . . . . . . 9
1.8 The first program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.9 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.10 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2 Variables, expressions and statements 15


2.1 Values and types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3 Variable names and keywords . . . . . . . . . . . . . . . . . . . . . . . . 17
2.4 Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.5 Operators and operands . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
x Contents

2.6 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.7 Order of operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.8 Modulus operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.9 String operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.10 Asking the user for input . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.11 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.12 Choosing mnemonic variable names . . . . . . . . . . . . . . . . . . . . 23
2.13 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.14 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.15 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

3 Conditional execution 29
3.1 Boolean expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.2 Logical operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.3 Conditional execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.4 Alternative execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.5 Chained conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.6 Nested conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.7 Catching exceptions using try and except . . . . . . . . . . . . . . . . . . 34
3.8 Short circuit evaluation of logical expressions . . . . . . . . . . . . . . . 35
3.9 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.10 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4 Functions 41
4.1 Function calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.2 Built-in functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.3 Type conversion functions . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.4 Random numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Contents xi

4.5 Math functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44


4.6 Adding new functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.7 Definitions and uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.8 Flow of execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.9 Parameters and arguments . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.10 Fruitful functions and void functions . . . . . . . . . . . . . . . . . . . . 49
4.11 Why functions? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.12 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.13 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.14 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

5 Iteration 55
5.1 Updating variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.2 The while statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.3 Infinite loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.4 “Infinite loops” and break . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.5 Finishing iterations with continue . . . . . . . . . . . . . . . . . . . . . 59
5.6 Definite loops using for . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.7 Loop patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.8 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.9 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.10 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

6 Strings 65
6.1 A string is a sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.2 Getting the length of a string using len . . . . . . . . . . . . . . . . . . . 66
6.3 Traversal through a string with a for loop . . . . . . . . . . . . . . . . . 66
6.4 String slices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
6.5 Strings are immutable . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
xii Contents

6.6 Searching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.7 Looping and counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.8 The in operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.9 String comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.10 string methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.11 Parsing strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.12 Format operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6.13 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.14 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.15 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

7 Files 81
7.1 Persistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.2 Opening files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
7.3 Text files and lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
7.4 Reading files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
7.5 Searching through a file . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.6 Letting the user choose the file name . . . . . . . . . . . . . . . . . . . . 87
7.7 Using try, catch, and open . . . . . . . . . . . . . . . . . . . . . . . 88
7.8 Writing files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.9 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.10 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

8 Lists 93
8.1 A list is a sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
8.2 Lists are mutable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
8.3 Traversing a list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
8.4 List operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Contents xiii

8.5 List slices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96


8.6 List methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.7 Deleting elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.8 Lists and strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
8.9 Parsing lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
8.10 Objects and values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
8.11 Aliasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
8.12 List arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
8.13 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
8.14 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
8.15 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

9 Dictionaries 109
9.1 Dictionary as a set of counters . . . . . . . . . . . . . . . . . . . . . . . 111
9.2 Dictionaries and files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
9.3 Looping and dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . 113
9.4 Advanced text parsing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
9.5 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
9.6 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
9.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

10 Tuples 119
10.1 Tuples are immutable . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
10.2 Comparing tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
10.3 Tuple assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
10.4 Dictionaries and tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
10.5 Multiple assignment with dictionaries . . . . . . . . . . . . . . . . . . . 123
10.6 The most common words . . . . . . . . . . . . . . . . . . . . . . . . . . 124
10.7 Using tuples as keys in dictionaries . . . . . . . . . . . . . . . . . . . . . 126
xiv Contents

10.8 Sequences: strings, lists, and tuples–Oh My! . . . . . . . . . . . . . . . . 127


10.9 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
10.10 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
10.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

11 Automating common tasks on your computer 131


11.1 File names and paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
11.2 Example: Cleaning up a photo directory . . . . . . . . . . . . . . . . . . 132
11.3 Command line arguments . . . . . . . . . . . . . . . . . . . . . . . . . . 138
11.4 Pipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
11.5 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
11.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

12 Networked programs 143


12.1 HyperText Transport Protocol - HTTP . . . . . . . . . . . . . . . . . . . 143
12.2 The World’s Simplest Web Browser . . . . . . . . . . . . . . . . . . . . 144
12.3 Retrieving web pages with urllib . . . . . . . . . . . . . . . . . . . . . 146
12.4 Parsing HTML and scraping the web . . . . . . . . . . . . . . . . . . . . 146
12.5 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
12.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

13 Using Web Services 151


13.1 eXtensible Markup Language - XML . . . . . . . . . . . . . . . . . . . . 151
13.2 Parsing XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
13.3 Looping through nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
13.4 Application Programming Interfaces (API) . . . . . . . . . . . . . . . . . 154
13.5 Twitter web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
13.6 Handling XML data from an API . . . . . . . . . . . . . . . . . . . . . . 157
13.7 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
13.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Contents xv

14 Using databases and Structured Query Language (SQL) 161


14.1 What is a database? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
14.2 Database concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
14.3 SQLite Database Browser . . . . . . . . . . . . . . . . . . . . . . . . . . 162
14.4 Creating a database table . . . . . . . . . . . . . . . . . . . . . . . . . . 163
14.5 Structured Query Language (SQL) summary . . . . . . . . . . . . . . . . 166
14.6 Spidering Twitter using a database . . . . . . . . . . . . . . . . . . . . . 167
14.7 Basic data modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
14.8 Programming with multiple tables . . . . . . . . . . . . . . . . . . . . . 175
14.9 Three kinds of keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
14.10 Using JOIN to retrieve data . . . . . . . . . . . . . . . . . . . . . . . . . 181
14.11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
14.12 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
14.13 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
14.14 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185

A Debugging 187
A.1 Syntax errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
A.2 Runtime errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
A.3 Semantic errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

B Contributor List 195


xvi Contents
Chapter 1

Why should you learn to write


programs?

Writing programs (or programming) is a very creative and rewarding activity. You can
write programs for many reasons ranging from making your living to solving a difficult
data analysis problem to having fun to helping someone else solve a problem. This book
assumes that everyone needs to know how to program and that once you know how to
program, you will figure out what you want to do with your newfound skills.
We are surrounded in our daily lives with computers ranging from laptops to cell phones.
We can think of these computers as our “personal assistants” who can take care of many
things on our behalf. The hardware in our current-day computers is essentially built to
continuously ask us the question, “What would you like me to do next?”.

What What What


Next? Next? Next?

What What What


PDA
Next? Next? Next?

Programmers add an operating system and a set of applications to the hardware and we
end up with a Personal Digital Assistant that is quite helpful and capable of helping many
different things.
Our computers are fast and have vast amounts of memory and could be very helpful to us
if we only knew the language to speak to explain to the computer what we would like it to
“do next”. If we knew this language we could tell the computer to do tasks on our behalf
that were repetitive. Interestingly, the kinds of things computers can do best are often the
kinds of things that we humans find boring and mind-numbing.
2 Chapter 1. Why should you learn to write programs?

For example, look at the first three paragraphs of this chapter and tell me the most com-
monly used word and how many times the word is used. While you were able to read and
understand the words in a few seconds, counting them is almost painful because it is not
the kind of problem that human minds are designed to solve. For a computer the opposite
is true, reading and understanding text from a piece of paper is hard for a computer to do
but counting the words and telling you how many times the most used word was used is
very easy for the computer:

python words.py
Enter file:words.txt
to 16

Our “personal information analysis assistant” quickly told us that the word “to” was used
sixteen times in the first three paragraphs of this chapter.

This very fact that computers are good at things that humans are not is why you need to
become skilled at talking “computer language”. Once you learn this new language, you can
delegate mundane tasks to your partner (the computer), leaving more time for you to do the
things that you are uniquely suited for. You bring creativity, intuition, and inventiveness to
this partnership.

1.1 Creativity and motivation


While this book is not intended for professional programmers, professional programming
can be a very rewarding job both financially and personally. Building useful, elegant, and
clever programs for others to use is a very creative activity. Your computer or Personal
Digital Assistant (PDA) usually contains many different programs from many different
groups of programmers, each competing for your attention and interest. They try their best
to meet your needs and give you a great user experience in the process. In some situations,
when you choose a piece of software, the programmers are directly compensated because
of your choice.

If we think of programs as the creative output of groups of programmers, perhaps the


following figure is a more sensible version of our PDA:

Pick Pick Pick


Me! Me! Me!

Pick Pick Buy


PDA
Me! Me! Me :)

For now, our primary motivation is not to make money or please end-users, but instead
for us to be more productive in handling the data and information that we will encounter
in our lives. When you first start, you will be both the programmer and end-user of your
1.2. Computer hardware architecture 3

programs. As you gain skill as a programmer and programming feels more creative to you,
your thoughts may turn toward developing programs for others.

1.2 Computer hardware architecture


Before we start learning the language we speak to give instructions to computers to develop
software, we need to learn a small amount about how computers are built. If you were to
take apart your computer or cell phone and look deep inside, you would find the following
parts:

What
Software Next?

Central
Input Processing
Output Network
Unit
Devices

Main
Secondary
Memory
Memory

The high-level definitions of these parts are as follows:

• The Central Processing Unit (or CPU) is that part of the computer that is built to be
obsessed with “what is next?”. If your computer is rated at 3.0 Gigahertz, it means
that the CPU will ask “What next?” three billion times per second. You are going to
have to learn how to talk fast to keep up with the CPU.
• The Main Memory is used to store information that the CPU needs in a hurry. The
main memory is nearly as fast as the CPU. But the information stored in the main
memory vanishes when the computer is turned off.
• The Secondary Memory is also used to store information, but it is much slower
than the main memory. The advantage of the secondary memory is that it can store
information even when there is no power to the computer. Examples of secondary
memory are disk drives or flash memory (typically found in USB sticks and portable
music players).
• The Input and Output Devices are simply our screen, keyboard, mouse, micro-
phone, speaker, touchpad, etc. They are all of the ways we interact with the com-
puter.
4 Chapter 1. Why should you learn to write programs?

• These days, most computers also have a Network Connection to retrieve informa-
tion over a network. We can think of the network as a very slow place to store and
retrieve data that might not always be “up”. So in a sense, the network is a slower
and at times unreliable form of Secondary Memory

While most of the detail of how these components work is best left to computer builders, it
helps to have a some terminology so we can talk about these different parts as we write our
programs.

As a programmer, your job is to use and orchestrate each of these resources to solve the
problem that you need solving and analyze the data you need. As a programmer you will
mostly be “talking” to the CPU and telling it what to do next. Sometimes you will tell the
CPU to use the main memory, secondary memory, network, or the input/output devices.

What
Software Next?

Central
Input Processing
Output Network
Unit
Devices

Main
Secondary
Memory
Memory
You

You need to be the person who answers the CPU’s “What next?” question. But it would be
very uncomfortable to shrink you down to 5mm tall and insert you into the computer just
so you could issue a command three billion times per second. So instead, you must write
down your instructions in advance. We call these stored instructions a program and the act
of writing these instructions down and getting the instructions to be correct programming.

1.3 Understanding programming


In the rest of this book, we will try to turn you into a person who is skilled in the art
of programming. In the end you will be a programmer — perhaps not a professional
programmer but at least you will have the skills to look at a data/information analysis
problem and develop a program to solve the problem.

In a sense, you need two skills to be a programmer:


1.4. The Python programming language 5

• First you need to know the programming language (Python) - you need to know the
vocabulary and the grammar. You need to be able spell the words in this new lan-
guage properly and how to construct well-formed “sentences” in this new languages.
• Second you need to “tell a story”. In writing a story, you combine words and sen-
tences to convey an idea to the reader. There is a skill and art in constructing the story
and skill in story writing is improved by doing some writing and getting some feed-
back. In programming, our program is the “story” and the problem you are trying to
solve is the “idea”.

Once you learn one programming language such as Python, you will find it much easier to
learn a second programming language such as JavaScript or C++. The new programming
language has very different vocabulary and grammar but once you learn problem solving
skills, they will be the same across all programming languages.
You will learn the “vocabulary” and “sentences” of Python pretty quickly. It will take
longer for you to be able to write a coherent program to solve a brand new problem. We
teach programming much like we teach writing. We start reading and explaining programs
and then we write simple programs and then write increasingly complex programs over
time. At some point you “get your muse” and see the patterns on your own and can see
more naturally how to take a problem and write a program that solves that problem. And
once you get to that point, programming becomes a very pleasant and creative process.
We start with the vocabulary and structure of Python programs. Be patient as the simple
examples remind you of when you started reading for the first time.

1.4 The Python programming language


The programming language you will learn is Python. Python is an example of a high-level
language; some other high-level languages you might have heard of are C, C++, Perl, Java,
Ruby, and JavaScript.
There are also low-level languages, sometimes referred to as “machine languages” or “as-
sembly languages.” Loosely speaking, computers can only execute programs written in
low-level languages. So programs written in a high-level language have to be processed
before they can run. This extra processing takes some time, which is a small disadvantage
of high-level languages.
However, the advantages are enormous. First, it is much easier to program in a high-level
language. Programs written in a high-level language take less time to write, they are shorter
and easier to read, and they are more likely to be correct. Second, high-level languages
are portable, meaning that they can run on different kinds of computers with few or no
modifications. Low-level programs can run on only one kind of computer and have to be
rewritten to run on another.
Due to these advantages, almost all programs are written in high-level languages. Low-
level languages are used only for a few specialized applications.
6 Chapter 1. Why should you learn to write programs?

Two kinds of programs process high-level languages into low-level languages: inter-
preters and compilers. An interpreter reads a high-level program and executes it, meaning
that it does what the program says. It processes the program a little at a time, alternately
reading lines and performing computations.

SOURCE INTERPRETER OUTPUT


CODE

A compiler reads the program and translates it completely before the program starts run-
ning. In this context, the high-level program is called the source code, and the translated
program is called the object code, machine code or the executable. Once a program is
compiled, you can execute it repeatedly without further translation.

SOURCE COMPILER OBJECT OUTPUT


EXECUTOR
CODE CODE

Python is considered an interpreted language because Python programs are executed by an


interpreter. There are two ways to use the interpreter: interactive mode and script mode.
To start interactive mode, you have to run the Python interpreter program. In a UNIX or
Windows command window, you would type python to run the Python interpreter.
In interactive mode, you type Python programs and the interpreter prints the result:

>>> 1 + 1
2
>>>

The chevron, >>>, is the prompt the interpreter uses to indicate that it is ready. If you type
1 + 1, the interpreter replies 2. The chevron is the Python interpreter’s way of asking you,
“What do you want me to do next?”. You will notice that as soon as Python finishes one
statement it immediately is ready for you to type another statement.
Typing commands into the Python interpreter is a great way to experiment with Python’s
features, but it is a bad way to type in many commands to solve a more complex problem.
When we want to write a program, we use a text editor to write the Python instructions into
a file, which is called a script. By convention, Python scripts have names that end with
.py.
To execute the script, you have to tell the interpreter the name of the file. In a UNIX or
Windows command window, you would type python dinsdale.py. In other development
environments, the details of executing scripts are different. You can find instructions for
your environment at the Python Website python.org.
1.5. What is a program? 7

Working in interactive mode is convenient for testing small pieces of code because you can
type and execute them immediately. But for anything more than a few lines, you should
save your code as a script so you can modify and execute it in the future.

1.5 What is a program?


A program is a sequence of instructions that specifies how to perform a computation.
The computation might be something mathematical, such as solving a system of equations
or finding the roots of a polynomial, but it can also be a symbolic computation, such as
searching and replacing text in a document or (strangely enough) compiling a program.

The details look different in different languages, but a few basic instructions appear in just
about every language:

input: Get data from the keyboard, a file, or some other device, pausing if necessary.

output: Display data on the screen or send data to a file or other device.

sequential execution: Perform statements one after another in the order they are encoun-
tered in the script.

conditional execution: Check for certain conditions and execute or skip a sequence of
statements.

repeated execution: Perform some set of statements repeatedly, usually with some varia-
tion.

reuse: Write a set of instructions once and give them a name and then reuse those instruc-
tions as needed throughout your program.

Believe it or not, that’s pretty much all there is to it. Every program you’ve ever used, no
matter how complicated, is made up of instructions that look pretty much like these. So you
can think of programming as the process of breaking a large, complex task into smaller and
smaller subtasks until the subtasks are simple enough to be performed with one of these
basic instructions.

1.6 What is debugging?


Programming is error-prone. For whimsical reasons, programming errors are called bugs
and the process of tracking them down is called debugging.

Three kinds of errors can occur in a program: syntax errors, runtime errors, and semantic
errors. It is useful to distinguish between them in order to track them down more quickly.
8 Chapter 1. Why should you learn to write programs?

1.6.1 Syntax errors


Python can only execute a program if the syntax is correct; otherwise, the interpreter dis-
plays an error message. Syntax refers to the structure of a program and the rules about that
structure. For example, parentheses have to come in matching pairs, so (1 + 2) is legal,
but 8) is a syntax error.
In English readers can tolerate most syntax errors, which is why we can read certain abstract
poetry. Python is not so forgiving. If there is a single syntax error anywhere in your
program, Python will display an error message and quit, and you will not be able to run
your program. During the first few weeks of your programming career, you will probably
spend a lot of time tracking down syntax errors. As you gain experience, you will make
fewer errors and find them faster.

1.6.2 Runtime errors


The second type of error is a runtime error, so called because the error does not appear until
after the program has started running. These errors are also called exceptions because they
usually indicate that something exceptional (and bad) has happened.
Runtime errors are rare in the simple programs you will see in the first few chapters, so it
might be a while before you encounter one.

1.6.3 Semantic errors


The third type of error is the semantic error. If there is a semantic error in your program,
it will run successfully in the sense that the computer will not generate any error messages,
but it will not do the right thing. It will do something else. Specifically, it will do what you
told it to do but not what you meant for it to do.
The problem is that the program you wrote is not the program you wanted to write. The
meaning of the program (its semantics) is wrong. Identifying semantic errors can be tricky
because it requires you to work backward by looking at the output of the program and
trying to figure out what it is doing.

1.6.4 Experimental debugging


One of the most important skills you will acquire is debugging. Although it can be frus-
trating, debugging is one of the most intellectually rich, challenging, and interesting parts
of programming.
In some ways, debugging is like detective work. You are confronted with clues, and you
have to infer the processes and events that led to the results you see.
Debugging is also like an experimental science. Once you have an idea about what is going
wrong, you modify your program and try again. If your hypothesis was correct, then you
1.7. Building “sentences” in Python 9

can predict the result of the modification, and you take a step closer to a working program.
If your hypothesis was wrong, you have to come up with a new one. As Sherlock Holmes
pointed out, “When you have eliminated the impossible, whatever remains, however im-
probable, must be the truth.” (A. Conan Doyle, The Sign of Four)
For some people, programming and debugging are the same thing. That is, programming
is the process of gradually debugging a program until it does what you want. The idea is
that you should start with a program that does something and make small modifications,
debugging them as you go, so that you always have a working program.
For example, Linux is an operating system that contains thousands of lines of code, but it
started out as a simple program Linus Torvalds used to explore the Intel 80386 chip. Ac-
cording to Larry Greenfield, “One of Linus’s earlier projects was a program that would
switch between printing AAAA and BBBB. This later evolved to Linux.” (The Linux
Users’ Guide Beta Version 1).
Later chapters will make more suggestions about debugging and other programming prac-
tices.

1.7 Building “sentences” in Python


The rules (or grammar) of Python are simpler and more precise than the rules of a natural
language that we use to speak and write.
Natural languages are the languages people speak, such as English, Spanish, and French.
They were not designed by people (although people try to impose some order on them);
they evolved naturally.
Formal languages are languages that are designed by people for specific applications. For
example, the notation that mathematicians use is a formal language that is particularly good
at denoting relationships among numbers and symbols. Chemists use a formal language to
represent the chemical structure of molecules. And most importantly:

Programming languages are formal languages that have been designed to


express computations.

Formal languages tend to have strict rules about syntax. For example, 3 + 3 = 6 is a syntac-
tically correct mathematical statement, but 3 + +3@6 is not. H2 O is a syntactically correct
chemical formula, but 2 Zz is not.
Syntax rules come in two flavors, pertaining to tokens and structure. Tokens are the basic
elements of the language, such as words, numbers, and chemical elements. One of the
problems with 3 + +3@6 is that @ is not a legal token in mathematics (at least as far as I
know). Similarly, 2 Zz is not legal because there is no element with the abbreviation Zz.
The second type of syntax error pertains to the structure of a statement; that is, the way the
tokens are arranged. The statement 3 + +3@6 is illegal because even though + is a legal
Random documents with unrelated
content Scribd suggests to you:
'Oh, nonsense, she will be there readily enough,' said her father; adding
—'I think I may be pardoned for saying it, Mr. Wilmot, but my Bella will be
the belle of the ball. However, leave us just now, dear. Mr. Wilmot has come
to see me on business, I doubt not, and that won't be interesting to you.'

She at once took up her work-basket, and withdrew, with a bow and a
smile, and Jerry, as his gaze followed her, and he saw what a perfect
creature she was, so slim and graceful with the pure complexion that comes
of health and country air, soft and sparkling brown eyes and rich hair coiled
round a shapely head, thought how unworthy it was of his mother to view
the girl as she did, and to treat her as she had hitherto done.

He knew exactly from what her indecision about the ball sprang. Never
before had she or her father been invited to the Manor House when other
guests were there, at dinner or garden parties, and when they had dined with
her and Miss Wilmot, in solitary state, she always resented bitterly the airs
of patronage which Lady Julia adopted.

'She's going to the ball, never fear, Mr. Jerry, and there is her reply on
the mantel-piece,' said her father.

'Permit me to be the bearer of it,' said Jerry, transferring it at once to his


pocket.

'And, now through the medium of some brandy and water, we shall turn
to business matters.'

'Glad to hear you say so,' replied Jerry; 'I have wished much to see you,
Chevenix, about money matters.'

Mr. Chevenix smiled faintly, and coughed slightly behind his hand.

'How has it been that of late so little has been paid into my bank
account,' said Jerry, 'and that I have had such difficulty in squaring matters
at Aldershot; even in meeting my losses on the last Divisional Steeplechase,
and in many other things; that in fact both the mater and myself are often
short of the "ready"?'
'The estate, you are aware, was heavily mortgaged by your late worthy
father.'

'I have heard that a hundred times, and know it to my cost,' replied
Jerry, impatiently.

'And since you joined the army you must also be aware that, to meet the
many requirements of yourself and Lady Julia, I have had to effect other
mortgages, for instance, on Langley Park (which my forefathers farmed
under yours for more than two centuries), on the forty acres of Upton Stoke,
and on Hazelwood; that, in short, all these may never be yours again, as I
see no way of your removing these encumbrances, save by a wealthy
marriage; and that the good lady, your mother, has not the slightest idea of
the extent of the evil and all your liabilities.'

'The devil!' exclaimed Jerry, 'these are pleasant things to listen to.'

There was a silence between them for a time, and Jerry took a long sip
at his brandy and seltzer. With all his admiration and certainly growing love
for the handsome Bella, she seemed to be receding from him in the distance
now.

'I am deeply sorry to tell you these things, Mr. Wilmot,' said Chevenix,
who had genuine respect and love for the listener, and really had the well-
being of the old family at heart; 'it is a serious thing for a young man like
you, the inheritor of a good old name, bred with expensive tastes and so
forth, to find yourself hampered and trammelled thus at your very outset of
life, but so it is.'

'We live and learn, Mr. Chevenix,' said Jerry, with unusual bitterness for
him.

'True,' added his old agent,

'We live and learn, but not the wiser grow, says John Pomfret.'

'And who the devil is he?' asked Jerry, testily.


'A poet and divine of the seventeenth century.'

Jerry sat staring into the fire as if bewildered by the sudden revelation—
this new state of things.

'And who holds all the infernal mortgages?' asked Jerry, abruptly.

'I do—they are in the iron safe on yonder shelf.'

'You; and who advanced all this money to my father, and to myself
latterly?'

'I did—every shilling to the old squire and to you, Mr. Jerry; but do not
be alarmed—do not be alarmed—I have no intention of foreclosing.'

Jerry was more thunderstruck than ever. Here was another startling
revelation. He found that more than half of his paternal estate was in the
hands of the very man whose daughter he had been learning to love in
secret, and whom his proud mother so heartily disliked and publicly
slighted.

He had hinted, as related, of mortgages on the evening of his arrival


with Bevil Goring, but this state of matters he was altogether unprepared
for. In short, it would seem as if but a moiety of his property remained to
him, and that the heiress of it all was Bella Chevenix!

Bella, the daughter of the village attorney, 'the lawyer man,' as Lady
Julia called him, whose forefathers did yeoman service to his, and farmed
old Langley Park.

'Take courage—you have yet time to look about you, and money, if it
can be procured from some other source, may repair these evils,' said Mr.
Chevenix, kindly; but he knew not what was then in Jerry's mind. That in
reality a love for Bella had been fast becoming the ruling thought of his life;
that on learning she had returned to Wilmothurst he had arranged to return
home also, and had made up his mind, despite his mother's pride and
opposition, to propose for the girl; but dared he do so now?
Their positions were completely reversed, and were he to do so she
would never believe in his love or view him as other than a pretender, who
offered it in barter for the mortgages her father held on his estate.

The latter was eyeing Jerry, and, having no idea of what his secret
thoughts were, failed to see why, if even a half of his estate remained, he
should seem so suddenly overcome, for he had grown very pale, and he
respired like one in pain.

To thrust all love for Bella out of his heart was now the bitter task to
which he must set himself, and perhaps to replace her image by one of the
many heiresses to whom his mother so often drew his attention; but that
could not be. Jolly, good-hearted Jerry would never condescend to be
mercenary; he felt that he would rather a thousand times share poverty with
a loving little girl like Bella than wealth with another. Matters had not yet
come to poverty—far from it; but now, and after all that had transpired, and
he had learned who the holder of these fatal mortgages was, how could he
speak to her or her father of love or marriage without being most cruelly
and degradingly misunderstood, and having his object utterly misconstrued?

'And the interest on the mortgages?' he asked, in a hard, dry tone.

'Has been unpaid for several years.'

'Making matters worse and worse. It was six per cent. on Langley Park,
Mr. Chevenix, and that is stiff interest as things go.'

'Yes, it was.'

'You speak of it in the past tense.'

'Yes.'

'Worse and worse,' assented Mr. Chevenix, shaking his white head. 'But
bear up, my dear boy. I may call you so?' added the old man, kindly patting
Jerry's shoulder. 'Money will pull you through. A handsome young fellow
like you, with your family prestige, will easily find a rich wife, and an
officer has a hundred chances of success when other fellows have none.'
Jerry had not the heart to ask what the total sum of his liabilities
amounted to, and rose to depart.

'Bid Miss Chevenix good-bye for me,' said he, as he departed in haste,
having just then no desire to add to the intense mortification that crushed
him by looking again on the bright face of the unconscious Bella—for
unconscious she was of what their mutual monetary relations were till her
father some time after informed her, when the news came to her perhaps too
late.

Sunk in thoughts too bitter for words, Jerry rode slowly home through
the dusk of the gloomy winter evening. The barriers raised by evil fortune,
and added to by a sense of honour and propriety, enhanced in his eyes the
value of the girl he felt that he had lost, and rendered dearer to him the
hopes he had been cherishing of late, and which had become so precious to
him.

He longed for the society and advice of Goring over a 'quiet weed' to
talk about these things ere he confided the state of matters to his mother,
who, with all her great love of him, he feared could not be brought to see
how matters stood with regard to the estate and the encumbrances thereon.

When he joined her in the drawing-room before dinner, the careworn


expression of his face—an expression all unusual to him—certainly struck
her, but for a time only.

'You have been with Mr. Chevenix?' she asked.

'Yes, mother.'

'And he has worried you with business.'

'Yes; his daughter is coming to the ball. Here is her reply; I brought it
with me,' said he, with an irrepressible sigh.

'Of course she will come; who ever doubted it?' responded Lady Julia,
as she somewhat contemptuously tossed Bella's unopened note into the fire;
and Jerry turned away to join Goring and his cousin Emily, who were
looking over a portfolio of prints upon a stand of gilded wood.

To Jerry at this precise time the familiar yet gorgeous drawing-room,


with all its inlaid cabinets and brackets, bearing treasures of art and bric-a-
brac, as seen under the soft light of wax candles in sconces and the
glittering crystal chandelier, gave a sense of worry by its apparent
incongruity, as did the very attire of his mother and cousin by the richness
of its materials, the laces, the jewelry; and he absolutely shivered when he
thought of the coming birthday ball, with its hundred and four guests on one
hand, and the mortgages of Chevenix with their unpaid interest on the other.

To Jerry it seemed that ere long his mother might have to betake herself
to Bruges or Boulogne to retrench, while he might have to exchange for
India if the route came not speedily for Africa.

Bevil Goring, when they were alone, heard with genuine concern the
state of affairs as Jerry set them before him, and agreed with him that to
continue his attentions to Miss Chevenix would lead to an entire
misconstruction on the part of herself and her father as to the true state of
his heart, and lead them to infer that he was only a fortune-hunter; and
honest Jerry blushed scarlet at the name, and twirled and gnawed his
moustache with intense irritation.

Though she failed to take in the whole situation—which Jerry knew


would be the case—Lady Julia heard his tidings with considerable alarm,
and felt her wrath increased against Mr. Chevenix, which was utterly
unreasonable.

'The state of our—or rather your—affairs, as this man has set them
before you, Jerry,' said Lady Julia, 'now renders it absolutely necessary that
you should marry for money, and that at once.'

'Or cut the service and emigrate,' groaned Jerry.

'Emigrate!'

'Invest in a pickaxe and spade, and try Ballarat or the Diamond Fields.'
'How can you jest thus?' said his mother, loftily.

'To me the nearest heiress seems to be Bella Chevenix,' said Jerry, not
unwilling to revenge her for the slighting remarks his mother daily made.

'She has a fortune certainly—a fortune won by advances made upon our
lands—but of what use can it be to her, brought up, as she has been,
ignorant of the habits, the tastes, and requirements of our class?'

'She is ignorant of none, and enjoys them all,' replied Jerry, with some
asperity.

'You inherited the estate encumbered, and have, in no small degree,


added to its burdens, and, if you do not make a rich marriage, may be—my
poor, dear Jerry—a ruined man.'

'We are going to fight King Koffee, they say. I'll get taken prisoner, and
marry his youngest daughter!' cried Jerry, with a gleam of his old
recklessness.

For some days now he did not go near Bella Chevenix, who began to
feel a little wroth at him in consequence, as she had no key as yet to what
influenced Jerry.

'Their ball!' exclaimed the proud girl, petulantly; 'I am not sure that I
should go, papa, to be patronised and slighted perhaps.'

'Patronised or slighted—who dare do either to you?' asked her father,


with surprise.

'I shall be bored to death, I fear.'

But the desire to appear where she knew she would shine prevailed over
all her doubts, and she devoted all her energies to have a costume that
should be second to none.

Meanwhile Jerry found the impossibility of abstaining entirely from


visiting the house of Mr. Chevenix, and so days of meetings in various ways
passed—meetings in which their lives seemed to be mutually merged in that
sweet occupation which was not quite love-making, but yet was far, far in
advance of that perilous frivolity that so often leads to it called—flirtation.

Yet Jerry was further now from disclosing himself than ever, and Bella
seemed in no hurry for him to do so, for she was young enough—even after
all she had seen of society—to shrink from a declaration, for to a girl there
is something so seductive, so sweet in hovering on the brink, when she, as
Bella did in her secret heart, loves the man.

Cousin Emily was not slow in discovering the direction in which Jerry
so often turned his horse's head, and hinted thereof to Lady Julia.

'But for the dangers my poor boy will have to encounter,' said the latter,
'I would hail with pleasure his departure to the coast of Africa, as a useful
means of separating him from this most artful creature.'

Meanwhile an influx of visitors and guests preluded the ball, as many


came from a considerable distance. Like Goring, Jerry was in no mood for
all this gaiety just then, and the latter resented that his duties as host
enforced his presence at Wilmothurst, and consequent absence from Bella
Chevenix.

CHAPTER XX.

THE FIREFLY.

The red sun of a clear winter day was shining on the two chalky
eminences at the embouchure of the Arques, or Bethune, and on the low
tongue of land between them, whereon is situated the seaport of Dieppe in
Normandy, from the church of which the coast of England can be distinctly
seen, when the Firefly, which really was a beautiful yacht, crept slowly
along on a wind under the lee of the shore, from which she was rather more
than a mile distant.

She was a taut-rigged craft of about two hundred tons, and whether one
regarded the crew, the fitting of the rigging, or the cut of the sails, it was
evident that in skilful hands she could do anything. For a Cowes yacht she
was curiously rigged, being a hermaphrodite—brig forward and schooner
aft. Her foremast, like her bowsprit, was strong and heavy, her mainmast
long and tapering. Her upper spars were slender and light, with topmast,
topgallant mast, and royal mast, all like slender wands, yet capable of
carrying a great amount of canvas. Her flush deck was white as the driven
snow, and she had eight six pounders, all brass, and polished like gold—
bright as the copper with which she was sheathed to the bends.

Such was the craft on board of which Alison Cheyne found herself a
species of prisoner, and compelled to take a part in an erratic and apparently
a purposeless cruise. To sail for Madeira had been the first intention of Lord
Cadbury, when Slagg, by his direction, inserted in the newspapers a
paragraph to the effect that he had gone to the Mediterranean—a paragraph
expressly designed to mislead Bevil Goring; but heavy head-winds had
prevailed, and after hanging about in 'the Chops of the Channel' for a week
and more, the Firefly was standing northward along the coast of France.

Tom Llanyard, Cadbury's captain, a bluff-looking, curly-haired man,


about forty years of age, had been for a brief space a warrant officer in the
Royal Navy. He was a good-hearted fellow—not very polished, but a
thorough seaman. He had a secret contempt for the character of his
employer, who did not care much for yachting, but thought it sounded well
to have such an appendage as the Firefly at Cowes. Tom found the pay
good; the lodging ditto; and the duty was easy. Tom was a sailor or nothing;
and thus being compelled to work, 'the yacht service,' as he used to say,
'suited him to a hair.'

He certainly thought the season a strange one for a cruise; and as for Mr.
Gaskins, Cadbury's groom and chief valet, he utterly loathed the whole
expedition, and, connecting it shrewdly in some way with Miss Cheyne, he
hated her with a most unholy hatred.
To Tom Llanyard she was a new experience; she was so totally unlike
any other of her sex he had seen on board the Firefly; and he had—we are
sorry to say—seen many that were rather remarkable.

The weather had been rough, and the poor girl, who had suffered much
from sea sickness, of a necessity remained below; while her luckless
attendant, Daisy Prune, was utterly prostrated by the same ailment, and the
order of things was now reversed, for Alison had to attend upon her. The
presence of Daisy, however, was a source of protection to the former, as it
saved her from much of the attention of Cadbury, who had hoped that great
events might be developed or achieved by the sea voyage.

Alison's freshness was delightful to the coarse, jaded man of the world,
who, tired at last of extravagant and congenial dissipation (that would have
horrified his worthy father the Alderman of Threadneedle Street), thought
now of trying domestic felicity, pour se désennuyer; and truly Alison was so
unlike most of the other women he had known, or whose acquaintance he
had chosen to cultivate, that the present opportunity gave him great
expectations of the future.

He actually reckoned upon a safe conquest, now that he had her all to
himself; and so far as Sir Ranald was concerned, while piling kindnesses
upon him, and pressing upon him also the best wines that the cellar of
Cadbury Court offered, he would not have been sorry had a gale of wind
blown the pompous old baronet overboard, and left Alison alone in the
world—alone, and at his mercy!

Leaving Sir Ranald busy with a telescope on deck scanning the


churches of St. Jacques and St. Remy, with Le Follet and the fisher town of
Dieppe, Cadbury descended to the luxurious and beautiful little cabin of the
yacht, the gilded and mahogany fittings of which were exquisite, and there
found Alison—alone, as he expected.

How sad and fair, young and pure, she looked in all the brightness of
her beauty, as her head rested against the crimson back of the cushioned
locker or sofa on which she was seated in an attitude expressive of utter
weariness of heart.
'Alison,' said he, attempting to take her hand.

Her eyes flashed now, and her proud little lip curled, as she said, 'Lord
Cadbury, when did I give you permission to call me—as papa does—by my
Christian name?'

'Why do you Lord me?' he asked; 'I would you called me—Timothy,' he
added, rather faintly; and at this absurd name a little smile flickered on
Alison's pale face, and a gesture of impatience escaped her, as she knew
that she was about to be subjected to some more of his odious and weary
love-making.

'My passion for you made me so modest and diffident,' said he (though
in reality it was his years), 'that I addressed myself first to your father,
though you were well aware of the sweet hopes I fostered in my heart,
Alison.'

'It is impossible for me to listen to more of this sort of thing, Lord


Cadbury.'

'I can scarcely believe that your decision is final—that you are in
earnest with me.'

'Earnest! Do you imagine, sir, that I would jest in this matter, and—and
with you?' she exclaimed, becoming—with all her native gentleness—
tremulous with suppressed passion.

'When once I ventured to hint of a deeper interest in you than mere


friendship, you did not discourage me,' urged Cadbury, who by use and
wont could make love in his own way pretty fluently now.

'Perhaps I misunderstood you,—or deemed it—deemed it——'

'What, Alison?'

'A fatherly interest.'

Cadbury winced a little at this remark.


'In anything beyond that,' continued Alison, 'you perhaps do me honour,
but in any instance I can never love where I do not respect and esteem.'

'And have I forfeited your esteem?'

'Yes.'

'In what way?'

'By trepanning me on board this yacht—away from home and my


friends!'

'Friends at Aldershot,' thought Cadbury, as he laughed to himself and


said,

'But why so severe a term as trepanning?'

'You led me to believe when we quitted Chilcote in such hot haste that
instant flight alone in this vessel would save papa from arrest through
certain bills which he says he saw you destroy. So you and he—he,' she
added, with a heavy sob—'have both deceived me, and now I believe
neither of you. It was a vile trick on the part of you both to separate me
from Captain Goring.'

Cadbury had reckoned at least upon her gratitude for taking up the bills
of Slagg, as he had to some extent won that of her father; but even this plan
failed to serve him, and so far as Alison was concerned he might as well
have thrown his money into the sea. The name of his rival on her lips
infuriated him, and he tugged at his long, white horse-shoe moustache
viciously, as he thought that he had played what he deemed his trump card,
and yet lost after all!

He gave her a glance of a rather mingled nature and retreated to the


deck, where his discomposure of face and manner was so apparent to Sir
Ranald that, after a few words of explanation, the latter sought the cabin to
remonstrate with the unfortunate and weary Alison.
As was before hinted, Sir Ranald's emotions were of a curiously
mingled nature. He felt that he certainly owed a debt of gratitude to Lord
Cadbury for relieving him of terrible monetary pressure, and he was
anxious, for various reasons, that Alison should accept him. He had no
romance in his nature—never had any, and did not believe that disparity of
years and tastes—still less a secret or previous fancy—were to be valued or
consulted at all!

He felt that he acted wisely to his daughter in leaguing with the wealthy
peer against her; yet, over and above all, he loved her dearly and tenderly;
and amid all this was an undying hostility to Bevil Goring, whom he
deemed the real cause of all this opposition to their wishes, and
consequently the present trouble, turmoil, and unnecessary voyaging in
rough and wintry weather.

Though it was a relief, without doubt, to be away now beyond the reach
or ken of the hook-nosed or vulture-eyed money-lenders, who, like Slagg,
had long possessed, among their ofttimes hopelessly-regarded assets, his
bills and acceptances.

He saw she looked pale, very pale indeed; but that, of course, he
attributed to the mal de mer; but as for love, no one, he believed, ever
sickened or died of that. A long separation was the surest and best cure.

'Foolish girl!' he began at once; 'still mooning, and actually talking, as


Cadbury told me, of that utterly ineligible and most detrimental fellow at
Aldershot; I am certain you could forget him if you tried, Alison. In these
days of ours, ninety-nine girls out of a hundred would leap with exultation
at such offers as those of Lord Cadbury.'

'Then, I suppose, I must be the hundredth girl, papa,' said Alison,


steadily and gravely; for a consciousness that her father, whom she had
deemed the mirror of honour, had leagued with this parvenu to deceive her,
had caused a change in her manner towards him.

'And I repeat that in these days of ours,' he continued, 'it is, or ought to
be, the object of both men and women to marry well.'
'That is, to marry for money,' said Alison.

'Yes; if a girl has beauty and birth, but not money, she should look for
some one who has that more than necessary element towards our very
existence. If she has money with both these attributes, she should look for
something more.'

'More, papa?'

'Yes, she should look for that which a poor girl seldom or never has
offered her.'

'And what is that?'

'A title.'

'In fact, in any way or every way to sell herself to the highest bidder.
Oh, what a selfish code!' exclaimed the girl, with great bitterness of heart.
'Did the Cheynes of Essilmont always do this?'

'They of old were not as we are now.'

'What?'

'Beggars!' replied her father, with equal bitterness of heart, for his was
naturally a proud one; 'but, as Lever says, "the world makes us many things
we never meant to be."'

'Do you forget, papa, that marriage is a sacrament, and that without a
full and perfect consent it is in reality no marriage at all, and should not be
binding, even though the blessing were given by the Archbishop of
Canterbury.'

'What do you mean, Alison?' asked her father, surprised alike by her
tone and this theory.

'Simply what I say.'

'How dare you, a mere girl, talk thus?'


'Take care, papa. If driven desperate, there is no knowing what I may—
not say—but do!'

Sir Ranald became silent. He had never seen her in this mood before;
and he, of course, ascribed it to 'the fatal influence that fellow Goring had
obtained over her mind.'

So this conversation ended; but the interview with her father and that
with Cadbury are but examples of many with which she was tormented
daily ad nauseam.

Alison ere long had fresh food for sorrow given to her, when a pilot
boat brought off to the Firefly some London papers, and in these she was
informed—as if by chance—there were rumours of the fast approaching
war in Africa, and she saw the glances, most meaning glances, of
satisfaction that were exchanged by her father and Lord Cadbury, on its
being announced that among the troops detailed for service in the field
under Sir Garnet Wolseley was the regiment of Bevil Goring; and so a
double and more terrible separation—perhaps a final and fatal one—was
before them, and the heart of the poor girl seemed to fill with tears as she
read and re-read the startling paragraph.

END OF THE FIRST VOLUME.

LONDON: PRINTED BY DUNCAN MACDONALD, BLENHEIM HOUSE.


*** END OF THE PROJECT GUTENBERG EBOOK MISS CHEYNE OF
ESSILMONT, VOLUME 1 (OF 3) ***

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.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

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. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

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.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• 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 provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

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.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
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!

ebookname.com

You might also like