100% found this document useful (15 votes)
176 views

Download Fundamentals of Python First Programs 1st Edition Kenneth A. Lambert ebook All Chapters PDF

Fundamentals

Uploaded by

georgpappev1
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 (15 votes)
176 views

Download Fundamentals of Python First Programs 1st Edition Kenneth A. Lambert ebook All Chapters PDF

Fundamentals

Uploaded by

georgpappev1
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/ 50

Download the full version of the ebook at ebookname.

com

Fundamentals of Python First Programs 1st Edition


Kenneth A. Lambert

https://ebookname.com/product/fundamentals-of-python-first-
programs-1st-edition-kenneth-a-lambert/

OR CLICK BUTTON

DOWNLOAD EBOOK

Download more ebook instantly today at https://ebookname.com


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

Python High Performance Programming Boost the performance


of your Python programs using advanced techniques 1st
Edition Gabriele Lanaro
https://ebookname.com/product/python-high-performance-programming-
boost-the-performance-of-your-python-programs-using-advanced-
techniques-1st-edition-gabriele-lanaro/
ebookname.com

Programming Fundamentals A Modular Structured Approach


Using C Kenneth Leroy Busbee

https://ebookname.com/product/programming-fundamentals-a-modular-
structured-approach-using-c-kenneth-leroy-busbee/

ebookname.com

Reflections of a Technocrat Managing Defense Air and Space


Programs During the 1st Edition John L. & Kenneth J.
Alnwick & Lawrence
https://ebookname.com/product/reflections-of-a-technocrat-managing-
defense-air-and-space-programs-during-the-1st-edition-john-l-kenneth-
j-alnwick-lawrence/
ebookname.com

Word 2010 For Dummies Dan Gookin

https://ebookname.com/product/word-2010-for-dummies-dan-gookin/

ebookname.com
Molecular Genetics and the Human Personality 1st ed
Edition Jonathan Benjamin

https://ebookname.com/product/molecular-genetics-and-the-human-
personality-1st-ed-edition-jonathan-benjamin/

ebookname.com

Wireless Information Networks Second Edition Kaveh


Pahlavan

https://ebookname.com/product/wireless-information-networks-second-
edition-kaveh-pahlavan/

ebookname.com

Hereditary Gynecologic Cancer Risk Prevention and


Management 1st Edition Karen H. Lu

https://ebookname.com/product/hereditary-gynecologic-cancer-risk-
prevention-and-management-1st-edition-karen-h-lu/

ebookname.com

Oxford Handbook of Urology 3rd Edition John Reynard

https://ebookname.com/product/oxford-handbook-of-urology-3rd-edition-
john-reynard/

ebookname.com

Design Basics Seventh Edition with ArtExperience Online


Printed Access Card David A. Lauer

https://ebookname.com/product/design-basics-seventh-edition-with-
artexperience-online-printed-access-card-david-a-lauer/

ebookname.com
Hypertension A Medical Dictionary Bibliography and
Annotated Research Guide to Internet References Health
Publica Icon Health Publications
https://ebookname.com/product/hypertension-a-medical-dictionary-
bibliography-and-annotated-research-guide-to-internet-references-
health-publica-icon-health-publications/
ebookname.com
Fundamentals of
Python:
First Programs

Kenneth A. Lambert
Martin Osborne, Contributing Author

Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
This is an electronic version of the print textbook. Due to electronic rights restrictions,
some third party content may be suppressed. Editorial review has deemed that any suppressed
content does not materially affect the overall learning experience. The publisher reserves the right
to remove content from this title at any time if subsequent rights restrictions require it. For
valuable information on pricing, previous editions, changes to current editions, and alternate
formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for
materials in your areas of interest.

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Fundamentals of Python: First Programs © 2012 Course Technology, Cengage Learning
Kenneth A. Lambert ALL RIGHTS RESERVED. No part of this work covered by the copyright
herein may be reproduced, transmitted, stored or used in any form or by
Executive Editor: Marie Lee
any means graphic, electronic, or mechanical, including but not limited to
Acquisitions Editor: Brandi Shailer photocopying, recording, scanning, digitizing, taping, Web distribution,
Senior Product Manager: Alyssa Pratt information networks, or information storage and retrieval systems, except
Development Editor: Ann Shaffer as permitted under Section 107 or 108 of the 1976 United States Copyright
Act, without the prior written permission of the publisher.
Associate Product Manager: Stephanie
Lorenz
For product information and technology assistance, contact us at
Associate Marketing Manager: Shanna
Cengage Learning Customer & Sales Support, 1-800-354-9706
Shelton
For permission to use material from this text or product, submit all
Content Project Manager: Jennifer Feltri requests online at www.cengage.com/permissions
Art Director: Faith Brosnan Further permissions questions can be emailed to
permissionrequest@cengage.com
Image credit: © istockphoto/Pei Ling Hoo
Cover Designer: Wing-ip Ngan,
Ink design, Inc. Library of Congress Control Number: 2011920241
Compositor: GEX Publishing Services ISBN-13: 978-1-111-82270-5
ISBN-10: 1-111-82270-0

Course Technology
20 Channel Center
Boston, Massachusetts 02210
USA

Cengage Learning is a leading provider of customized learning solutions


with office locations around the globe, including Singapore, the United
Kingdom, Australia, Mexico, Brazil, and Japan. Locate your local office at:
international.cengage.com/region

Cengage Learning products are represented in Canada by Nelson


Education, Ltd.

For your lifelong learning solutions, visit course.cengage.com.

Purchase any of our products at your local college store or at our preferred
online store www.cengagebrain.com.

Some of the product names and company names used in this book have
been used for identification purposes only and may be trademarks or regis-
tered trademarks of their respective manufacturers and sellers.

Any fictional data related to persons or companies or URLs used through-


out this book is intended for instructional purposes only. At the time this
book was printed, any such data was fictional and not belonging to any real
persons or companies.

Course Technology, a part of Cengage Learning, reserves the right to revise this
publication and make changes from time to time in its content without notice.

The programs in this book are for instructional purposes only.


They have been tested with care, but are not guaranteed for any particular
intent beyond educational purposes. The author and the publisher do not
offer any warranties or representations, nor do they accept any liabilities
Printed in the United States of America with respect to the programs.
1 2 3 4 5 6 7 15 14 13 12 11

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Table of Contents
[CHAPTER] 1 INTRODUCTION 1
1.1 Two Fundamental Ideas of Computer Science: Algorithms and Information
Processing .................................................................................................................2
1.1.1 Algorithms ................................................................................................2
1.1.2 Information Processing............................................................................4
1.1 Exercises....................................................................................................................5
1.2 The Structure of a Modern Computer System .......................................................6
1.2.1 Computer Hardware ................................................................................6
1.2.2 Computer Software..................................................................................8
1.2 Exercises..................................................................................................................10
1.3 A Not-So-Brief History of Computing Systems...................................................10
1.3.1 Before Electronic Digital Computers ...................................................11
1.3.2 The First Electronic Digital Computers (1940–1950) .........................15
1.3.3 The First Programming Languages (1950–1965).................................16
1.3.4 Integrated Circuits, Interaction, and Timesharing (1965–1975) .........18
1.3.5 Personal Computing and Networks (1975–1990) ................................19
1.3.6 Consultation, Communication, and Ubiquitous Computing
(1990–Present)........................................................................................21
1.4 Getting Started with Python Programming..........................................................23
1.4.1 Running Code in the Interactive Shell .................................................23
1.4.2 Input, Processing, and Output...............................................................25
1.4.3 Editing, Saving, and Running a Script ..................................................28
1.4.4 Behind the Scenes: How Python Works ...............................................29
1.4 Exercises..................................................................................................................30
1.5 Detecting and Correcting Syntax Errors...............................................................31
1.5 Exercises..................................................................................................................32
Suggestions for Further Reading ...........................................................................32
Summary .................................................................................................................33
Review Questions ...................................................................................................35
Projects....................................................................................................................37

[CHAPTER] 2 SOFTWARE DEVELOPMENT, DATA TYPES, AND


EXPRESSIONS 39
2.1 The Software Development Process .....................................................................40
2.1 Exercises..................................................................................................................43
2.2 Case Study: Income Tax Calculator.......................................................................43
2.2.1 Request ...................................................................................................43
2.2.2 Analysis ...................................................................................................44
2.2.3 Design.....................................................................................................44
2.2.4 Implementation (Coding) ......................................................................45
2.2.5 Testing ....................................................................................................46

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.3 Strings, Assignment, and Comments.....................................................................47
2.3.1 Data Types..............................................................................................47
2.3.2 String Literals.........................................................................................48
2.3.3 Escape Sequences ...................................................................................50
2.3.4 String Concatenation .............................................................................50
2.3.5 Variables and the Assignment Statement ..............................................51
2.3.6 Program Comments and Docstrings.....................................................52
2.3 Exercises..................................................................................................................53
2.4 Numeric Data Types and Character Sets ..............................................................54
2.4.1 Integers ...................................................................................................54
2.4.2 Floating-Point Numbers........................................................................55
2.4.3 Character Sets ........................................................................................55
2.4 Exercises..................................................................................................................57
2.5 Expressions .............................................................................................................58
2.5.1 Arithmetic Expressions ..........................................................................58
2.5.2 Mixed-Mode Arithmetic and Type Conversions ..................................60
2.5 Exercises..................................................................................................................63
2.6 Using Functions and Modules ...............................................................................63
2.6.1 Calling Functions: Arguments and Return Values................................64
2.6.2 The math Module .................................................................................65
2.6.3 The Main Module..................................................................................66
2.6.4 Program Format and Structure .............................................................67
2.6.5 Running a Script from a Terminal Command Prompt ........................68
2.6 Exercises..................................................................................................................70
Summary .................................................................................................................70
Review Questions ...................................................................................................72
Projects....................................................................................................................73

[CHAPTER] 3 CONTROL STATEMENTS 75


3.1 Definite Iteration: The for Loop.........................................................................76
3.1.1 Executing a Statement a Given Number of Times ..............................76
3.1.2 Count-Controlled Loops .......................................................................77
3.1.3 Augmented Assignment .........................................................................79
3.1.4 Loop Errors: Off-by-One Error............................................................80
3.1.5 Traversing the Contents of a Data Sequence........................................80
3.1.6 Specifying the Steps in the Range .........................................................81
3.1.7 Loops That Count Down ......................................................................82
3.1 Exercises..................................................................................................................83
3.2 Formatting Text for Output ...................................................................................83
3.2 Exercises..................................................................................................................86
3.3 Case Study: An Investment Report........................................................................87
3.3.1 Request ...................................................................................................87
3.3.2 Analysis ...................................................................................................87
3.3.3 Design.....................................................................................................88
3.3.4 Implementation (Coding) ......................................................................88
3.3.5 Testing ....................................................................................................90
3.4 Selection: if and if-else Statements ...............................................................91
3.4.1 The Boolean Type, Comparisons, and Boolean Expressions ...............91
3.4.2 if-else Statements .............................................................................92

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.4.3 One-Way Selection Statements.............................................................94
3.4.4 Multi-way if Statements ......................................................................95
3.4.5 Logical Operators and Compound Boolean Expressions.....................97
3.4.6 Short-Circuit Evaluation .......................................................................99
3.4.7 Testing Selection Statements ...............................................................100
3.4 Exercises................................................................................................................101
3.5 Conditional Iteration: The while Loop ............................................................102
3.5.1 The Structure and Behavior of a while Loop ..................................102
3.5.2 Count Control with a while Loop....................................................104
3.5.3 The while True Loop and the break Statement ..........................105
3.5.4 Random Numbers................................................................................107
3.5.5 Loop Logic, Errors, and Testing .........................................................109
3.5 Exercises................................................................................................................109
3.6 Case Study: Approximating Square Roots...........................................................110
3.6.1 Request .................................................................................................110
3.6.2 Analysis .................................................................................................110
3.6.3 Design...................................................................................................110
3.6.4 Implementation (Coding) ....................................................................112
3.6.5 Testing ..................................................................................................113
Summary ...............................................................................................................113
Review Questions .................................................................................................116
Projects..................................................................................................................118

[CHAPTER] 4 STRINGS AND TEXT FILES 121


4.1 Accessing Characters and Substrings in Strings..................................................122
4.1.1 The Structure of Strings......................................................................122
4.1.2 The Subscript Operator.......................................................................123
4.1.3 Slicing for Substrings ...........................................................................124
4.1.4 Testing for a Substring with the in Operator ....................................125
4.1 Exercises................................................................................................................126
4.2 Data Encryption ...................................................................................................126
4.2 Exercises................................................................................................................129
4.3 Strings and Number Systems...............................................................................129
4.3.1 The Positional System for Representing Numbers............................130
4.3.2 Converting Binary to Decimal ............................................................131
4.3.3 Converting Decimal to Binary ............................................................132
4.3.4 Conversion Shortcuts...........................................................................133
4.3.5 Octal and Hexadecimal Numbers .......................................................134
4.3 Exercises................................................................................................................136
4.4 String Methods .....................................................................................................136
4.4 Exercises................................................................................................................140
4.5 Text Files...............................................................................................................141
4.5.1 Text Files and Their Format................................................................141
4.5.2 Writing Text to a File ..........................................................................142
4.5.3 Writing Numbers to a File ..................................................................142
4.5.4 Reading Text from a File .....................................................................143
4.5.5 Reading Numbers from a File .............................................................145
4.5.6 Accessing and Manipulating Files and Directories on Disk...............146

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
4.5 Exercises................................................................................................................148
4.6 Case Study: Text Analysis.....................................................................................148
4.6.1 Request .................................................................................................149
4.6.2 Analysis .................................................................................................149
4.6.3 Design...................................................................................................150
4.6.4 Implementation (Coding) ....................................................................151
4.6.5 Testing ..................................................................................................152
Summary ...............................................................................................................153
Review Questions .................................................................................................154
Projects..................................................................................................................156

[CHAPTER] 5 LISTS AND DICTIONARIES 159


5.1 Lists .......................................................................................................................160
5.1.1 List Literals and Basic Operators ........................................................160
5.1.2 Replacing an Element in a List ...........................................................163
5.1.3 List Methods for Inserting and Removing Elements .........................165
5.1.4 Searching a List....................................................................................167
5.1.5 Sorting a List........................................................................................168
5.1.6 Mutator Methods and the Value None ...............................................168
5.1.7 Aliasing and Side Effects......................................................................169
5.1.8 Equality: Object Identity and Structural Equivalence........................171
5.1.9 Example: Using a List to Find the Median of a Set of Numbers ......172
5.1.10 Tuples ...................................................................................................173
5.1 Exercises................................................................................................................174
5.2 Defining Simple Functions ..................................................................................175
5.2.1 The Syntax of Simple Function Definitions .......................................175
5.2.2 Parameters and Arguments..................................................................176
5.2.3 The return Statement.......................................................................177
5.2.4 Boolean Functions................................................................................177
5.2.5 Defining a main Function...................................................................178
5.2 Exercises................................................................................................................179
5.3 Case Study: Generating Sentences ......................................................................179
5.3.1 Request .................................................................................................179
5.3.2 Analysis .................................................................................................179
5.3.3 Design...................................................................................................180
5.3.4 Implementation (Coding) ....................................................................182
5.3.5 Testing ..................................................................................................183
5.4 Dictionaries...........................................................................................................183
5.4.1 Dictionary Literals ...............................................................................183
5.4.2 Adding Keys and Replacing Values .....................................................184
5.4.3 Accessing Values...................................................................................185
5.4.4 Removing Keys ....................................................................................186
5.4.5 Traversing a Dictionary .......................................................................186
5.4.6 Example: The Hexadecimal System Revisited....................................188
5.4.7 Example: Finding the Mode of a List of Values .................................189
5.4 Exercises................................................................................................................190

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
5.5 Case Study: Nondirective Psychotherapy ...........................................................191
5.5.1 Request .................................................................................................191
5.5.2 Analysis .................................................................................................191
5.5.3 Design...................................................................................................192
5.5.4 Implementation (Coding) ....................................................................193
5.5.5 Testing ..................................................................................................195
Summary ...............................................................................................................195
Review Questions .................................................................................................196
Projects..................................................................................................................198

[CHAPTER] 6 DESIGN WITH FUNCTIONS 201


6.1 Functions as Abstraction Mechanisms.................................................................202
6.1.1 Functions Eliminate Redundancy........................................................202
6.1.2 Functions Hide Complexity ................................................................203
6.1.3 Functions Support General Methods with Systematic Variations .....204
6.1.4 Functions Support the Division of Labor ...........................................205
6.1 Exercises................................................................................................................205
6.2 Problem Solving with Top-Down Design ...........................................................206
6.2.1 The Design of the Text-Analysis Program .........................................206
6.2.2 The Design of the Sentence-Generator Program ..............................207
6.2.3 The Design of the Doctor Program ...................................................209
6.2 Exercises................................................................................................................210
6.3 Design with Recursive Functions ........................................................................211
6.3.1 Defining a Recursive Function ............................................................211
6.3.2 Tracing a Recursive Function ..............................................................213
6.3.3 Using Recursive Definitions to Construct Recursive Functions .......214
6.3.4 Recursion in Sentence Structure .........................................................214
6.3.5 Infinite Recursion.................................................................................215
6.3.6 The Costs and Benefits of Recursion..................................................216
6.3 Exercises................................................................................................................218
6.4 Case Study: Gathering Information from a File System ....................................219
6.4.1 Request .................................................................................................219
6.4.2 Analysis .................................................................................................220
6.4.3 Design...................................................................................................222
6.4.4 Implementation (Coding) ....................................................................224
6.5 Managing a Program’s Namespace ......................................................................227
6.5.1 Module Variables, Parameters, and Temporary Variables ..................227
6.5.2 Scope.....................................................................................................228
6.5.3 Lifetime ................................................................................................229
6.5.4 Default (Keyword) Arguments ............................................................230
6.5 Exercises................................................................................................................232
6.6 Higher-Order Functions (Advanced Topic) ........................................................233
6.6.1 Functions as First-Class Data Objects ................................................233
6.6.2 Mapping................................................................................................234
6.6.3 Filtering ................................................................................................236
6.6.4 Reducing...............................................................................................237
6.6.5 Using lambda to Create Anonymous Functions...............................237
6.6.6 Creating Jump Tables ..........................................................................238

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
6.6 Exercises................................................................................................................239
Summary ...............................................................................................................240
Review Questions .................................................................................................242
Projects..................................................................................................................244

[CHAPTER] 7 SIMPLE GRAPHICS AND IMAGE PROCESSING 247


7.1 Simple Graphics ...................................................................................................248
7.1.1 Overview of Turtle Graphics ...............................................................248
7.1.2 Turtle Operations.................................................................................249
7.1.3 Object Instantiation and the turtle Module ...................................252
7.1.4 Drawing Two-Dimensional Shapes .....................................................254
7.1.5 Taking a Random Walk........................................................................255
7.1.6 Colors and the RGB System................................................................256
7.1.7 Example: Drawing with Random Colors ............................................257
7.1.8 Examining an Object’s Attributes ........................................................259
7.1.9 Manipulating a Turtle’s Screen ............................................................259
7.1.10 Setting up a cfg File and Running IDLE..........................................260
7.1 Exercises................................................................................................................261
7.2 Case Study: Recursive Patterns in Fractals..........................................................262
7.2.1 Request .................................................................................................263
7.2.2 Analysis .................................................................................................263
7.2.3 Design...................................................................................................264
7.2.4 Implementation (Coding) ....................................................................266
7.3 Image Processing .................................................................................................267
7.3.1 Analog and Digital Information .........................................................267
7.3.2 Sampling and Digitizing Images .........................................................268
7.3.3 Image File Formats ..............................................................................268
7.3.4 Image-Manipulation Operations .........................................................269
7.3.5 The Properties of Images ....................................................................270
7.3.6 The images Module ..........................................................................270
7.3.7 A Loop Pattern for Traversing a Grid ................................................274
7.3.8 A Word on Tuples................................................................................275
7.3.9 Converting an Image to Black and White ..........................................276
7.3.10 Converting an Image to Grayscale......................................................278
7.3.11 Copying an Image ................................................................................279
7.3.12 Blurring an Image ................................................................................280
7.3.13 Edge Detection ....................................................................................281
7.3.14 Reducing the Image Size .....................................................................282
7.3 Exercises................................................................................................................284
Summary ...............................................................................................................285
Review Questions .................................................................................................286
Projects..................................................................................................................288

[CHAPTER] 8 DESIGN WITH CLASSES 293


8.1 Getting Inside Objects and Classes .....................................................................294
8.1.1 A First Example: The Student Class................................................295
8.1.2 Docstrings ............................................................................................298
8.1.3 Method Definitions..............................................................................298

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
8.1.4 The __init__ Method and Instance Variables................................299
8.1.5 The __str__ Method........................................................................300
8.1.6 Accessors and Mutators .......................................................................300
8.1.7 The Lifetime of Objects ......................................................................301
8.1.8 Rules of Thumb for Defining a Simple Class.....................................302
8.1 Exercises................................................................................................................303
8.2 Case Study: Playing the Game of Craps .............................................................303
8.2.1 Request .................................................................................................303
8.2.2 Analysis .................................................................................................303
8.2.3 Design...................................................................................................304
8.2.4 Implementation (Coding) ....................................................................306
8.3 Data-Modeling Examples.....................................................................................309
8.3.1 Rational Numbers ................................................................................309
8.3.2 Rational Number Arithmetic and Operator Overloading..................311
8.3.3 Comparison Methods...........................................................................312
8.3.4 Equality and the __eq__ Method ......................................................314
8.3.5 Savings Accounts and Class Variables .................................................315
8.3.6 Putting the Accounts into a Bank........................................................317
8.3.7 Using pickle for Permanent Storage of Objects.............................319
8.3.8 Input of Objects and the try-except Statement............................320
8.3.9 Playing Cards .......................................................................................321
8.3 Exercises................................................................................................................325
8.4 Case Study: An ATM............................................................................................325
8.4.1 Request .................................................................................................325
8.4.2 Analysis .................................................................................................325
8.4.3 Design...................................................................................................327
8.4.4 Implementation (Coding) ....................................................................329
8.5 Structuring Classes with Inheritance and Polymorphism...................................331
8.5.1 Inheritance Hierarchies and Modeling ...............................................332
8.5.2 Example: A Restricted Savings Account..............................................333
8.5.3 Example: The Dealer and a Player in the Game of Blackjack ...........335
8.5.4 Polymorphic Methods..........................................................................340
8.5.5 Abstract Classes ...................................................................................340
8.5.6 The Costs and Benefits of Object-Oriented Programming...............341
8.5 Exercises................................................................................................................343
Summary ...............................................................................................................343
Review Questions .................................................................................................345
Projects..................................................................................................................346

[CHAPTER] 9 GRAPHICAL USER INTERFACES 349


9.1 The Behavior of Terminal-Based Programs and GUI-Based Programs............350
9.1.1 The Terminal-Based Version ...............................................................350
9.1.2 The GUI-Based Version......................................................................351
9.1.3 Event-Driven Programming................................................................353
9.1 Exercises................................................................................................................355
9.2 Coding Simple GUI-Based Programs .................................................................355
9.2.1 Windows and Labels............................................................................356
9.2.2 Displaying Images ................................................................................357
9.2.3 Command Buttons and Responding to Events...................................358
9.2.4 Viewing the Images of Playing Cards .................................................360

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
9.2.5 Entry Fields for the Input and Output of Text ...................................363
9.2.6 Using Pop-up Dialog Boxes ................................................................365
9.2 Exercises................................................................................................................366
9.3 Case Study: A GUI-Based ATM..........................................................................367
9.3.1 Request .................................................................................................367
9.3.2 Analysis .................................................................................................367
9.3.3 Design...................................................................................................368
9.3.4 Implementation (Coding) ....................................................................369
9.4 Other Useful GUI Resources ..............................................................................372
9.4.1 Colors ...................................................................................................373
9.4.2 Text Attributes......................................................................................373
9.4.3 Sizing and Justifying an Entry .............................................................374
9.4.4 Sizing the Main Window.....................................................................375
9.4.5 Grid Attributes .....................................................................................376
9.4.6 Using Nested Frames to Organize Components................................380
9.4.7 Multi-Line Text Widgets .....................................................................381
9.4.8 Scrolling List Boxes .............................................................................384
9.4.9 Mouse Events .......................................................................................387
9.4.10 Keyboard Events ..................................................................................388
9.4 Exercises................................................................................................................389
Summary ...............................................................................................................390
Review Questions .................................................................................................391
Projects..................................................................................................................392

[CHAPTER] 10 MULTITHREADING, NETWORKS, AND CLIENT/SERVER


PROGRAMMING 395
10.1 Threads and Processes .........................................................................................396
10.1.1 Threads.................................................................................................397
10.1.2 Sleeping Threads..................................................................................400
10.1.3 Producer, Consumer, and Synchronization ........................................402
10.1 Exercises................................................................................................................409
10.2 Networks, Clients, and Servers............................................................................409
10.2.1 IP Addresses .........................................................................................409
10.2.2 Ports, Servers, and Clients...................................................................411
10.2.3 Sockets and a Day/Time Client Script................................................412
10.2.4 A Day/Time Server Script ...................................................................414
10.2.5 A Two-Way Chat Script.......................................................................416
10.2.6 Handling Multiple Clients Concurrently ...........................................418
10.2.7 Setting Up Conversations for Others .................................................420
10.2 Exercises................................................................................................................422
10.3 Case Study: A Multi-Client Chat Room .............................................................423
10.3.1 Request ................................................................................................423
10.3.2 Analysis ................................................................................................423
10.3.3 Design...................................................................................................424
10.3.4 Implementation (Coding) ....................................................................425
Summary ...............................................................................................................427
Review Questions .................................................................................................428
Projects..................................................................................................................430

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
[ONLINE CHAPTER] 11 SEARCHING, SORTING, AND COMPLEXITY ANALYSIS

11.1 Measuring the Efficiency of Algorithms


11.1.1 Measuring the Run Time of an Algorithm
11.1.2 Counting Instructions
11.1.3 Measuring the Memory Used by an Algorithm
11.1 Exercises
11.2 Complexity Analysis
11.2.1 Orders of Complexity
11.2.2 Big-O Notation
11.2.3 The Role of the Constant of Proportionality
11.2 Exercises
11.3 Search Algorithms
11.3.1 Search for a Minimum
11.3.2 Linear Search of a List
11.3.3 Best-Case, Worst-Case, and Average-Case Performance
11.3.4 Binary Search of a List
11.3.5 Comparing Data Items
11.3 Exercises
11.4 Sort Algorithms
11.4.1 Selection Sort
11.4.2 Bubble Sort
11.4.3 Insertion Sort
11.4.4 Best-Case, Worst-Case, and Average-Case Performance Revisited
11.4 Exercises
11.5 An Exponential Algorithm: Recursive Fibonacci
11.6 Converting Fibonacci to a Linear Algorithm
11.7 Case Study: An Algorithm Profiler
11.7.1 Request
11.7.2 Analysis
11.7.3 Design
11.7.4 Implementation (Coding)
Summary
Review Questions
Projects

[APPENDIX] A PYTHON RESOURCES 433


A.1 Installing Python on Your Computer ..................................................................434
A.2 Using the Terminal Command Prompt, IDLE, and Other IDEs......................434

[APPENDIX] B INSTALLING THE images LIBRARY 437


[APPENDIX] C API FOR IMAGE PROCESSING 439
[APPENDIX] D TRANSITION FROM PYTHON TO JAVA AND C++ 441
GLOSSARY 443
INDEX 455
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
PREFACE
Welcome to Fundamentals of Python: First Programs. This text is intended for a
course in programming and problem-solving. It covers the material taught in a
typical Computer Science 1 course (CS1) at the undergraduate level.
This book covers five major aspects of computing:
1 Programming Basics—Data types, control structures, algorithm devel-
opment, and program design with functions are basic ideas that you need
to master in order to solve problems with computers. This book exam-
ines these core topics in detail and gives you practice employing your
understanding of them to solve a wide range of problems.
2 Object-Oriented Programming (OOP)—Object-Oriented
Programming is the dominant programming paradigm used to develop
large software systems. This book introduces you to the fundamental
principles of OOP and enables you to apply them successfully.
3 Data and Information Processing—Most useful programs rely on data
structures to solve problems. These data structures include strings,
arrays, files, lists, and dictionaries. This book introduces you to these
commonly used data structures, with examples that illustrate criteria for
selecting the appropriate data structures for given problems.
4 Software Development Life Cycle—Rather than isolate software
development techniques in one or two chapters, this book deals with
them throughout in the context of numerous case studies. Among other
things, you’ll learn that coding a program is often not the most difficult
or challenging aspect of problem solving and software development.
5 Contemporary Applications of Computing—The best way to learn
about programming and problem solving is to create interesting programs
with real-world applications. In this book, you’ll begin by creating applica-
tions that involve numerical problems and text processing. For example,
you’ll learn the basics of encryption techniques such as those that are used
to make your credit card number and other information secure on the
Internet. But unlike many other introductory texts, this one does not
restrict itself to problems involving numbers and text. Most contemporary
applications involve graphical user interfaces, event-driven programming,
graphics, and network communications. These topics are presented in
optional, standalone chapters.

PREFACE [ xiii ]

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Why Python?
Computer technology and applications have become increasingly more sophisti-
cated over the past two decades, and so has the computer science curriculum, espe-
cially at the introductory level. Today’s students learn a bit of programming and
problem–solving, and are then expected to move quickly into topics like software
development, complexity analysis, and data structures that, twenty years ago, were
relegated to advanced courses. In addition, the ascent of object-oriented program-
ming as the dominant paradigm of problem solving has led instructors and text-
book authors to bring powerful, industrial-strength programming languages such as
C++ and Java into the introductory curriculum. As a result, instead of experiencing
the rewards and excitement of solving problems with computers, beginning com-
puter science students often become overwhelmed by the combined tasks of mas-
tering advanced concepts as well as the syntax of a programming language.
This book uses the Python programming language as a way of making the
first year of computer science more manageable and attractive for students and
instructors alike. Python has the following pedagogical benefits:
 Python has simple, conventional syntax. Python statements are very close to

those of pseudocode algorithms, and Python expressions use the conven-


tional notation found in algebra. Thus, students can spend less time learn-
ing the syntax of a programming language and more time learning to solve
interesting problems.
 Python has safe semantics. Any expression or statement whose meaning

violates the definition of the language produces an error message.


 Python scales well. It is very easy for beginners to write simple programs in

Python. Python also includes all of the advanced features of a modern pro-
gramming language, such as support for data structures and object-oriented
software development, for use when they become necessary.
 Python is highly interactive. Expressions and statements can be entered at

an interpreter’s prompts to allow the programmer to try out experimental


code and receive immediate feedback. Longer code segments can then be
composed and saved in script files to be loaded and run as modules or
standalone applications.
 Python is general purpose. In today’s context, this means that the language

includes resources for contemporary applications, including media comput-


ing and networks.
 Python is free and is in widespread use in industry. Students can download

Python to run on a variety of devices. There is a large Python user com-


munity, and expertise in Python programming has great resume value.

[ xiv ] PREFACE

Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of The
Evacuation of England: The Twist in the Gulf
Stream
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.

Title: The Evacuation of England: The Twist in the Gulf Stream

Author: L. P. Gratacap

Release date: June 10, 2021 [eBook #65588]


Most recently updated: October 12, 2022

Language: English

Credits: E-text prepared by Tim Lindell, Charlie Howard, and the


Online Distributed Proofreading Team
(http://www.pgdp.net) from page images digitized by
the Google Books Library Project
(https://books.google.com) and generously made
available by HathiTrust Digital Library
(https://www.hathitrust.org/)

*** START OF THE PROJECT GUTENBERG EBOOK THE EVACUATION


OF ENGLAND: THE TWIST IN THE GULF STREAM ***
E-text prepared by Tim Lindell, Charlie Howard,
and the Online Distributed Proofreading Team
(http://www.pgdp.net)
from page images digitized by
the Google Books Library Project
(https://books.google.com)
and generously made available by
HathiTrust Digital Library
(https://www.hathitrust.org/)

Note: Images of the original pages are available


through HathiTrust Digital Library. See
https://hdl.handle.net/2027/nyp.33433074864483

THE EVACUATION OF
ENGLAND
THE
Evacuation of England
THE TWIST IN THE GULF STREAM

BY
L. P. GRATACAP
AUTHOR OF
“THE CERTAINTY OF A FUTURE LIFE IN MARS,”
“A WOMAN OF THE ICE AGE”

NEW YORK
B R E N TA N O ’ S
1908
Copyright, 1908, by Brentano’s
CONTENTS
CHAPTER PAGE
I. In Washington, April, 1909 5

II. The Lecture 38

III. Baltimore, May 29, 1909 66

IV. Gettysburg, May 30, 1909 102

V. The Eviction of Scotland 131

VI. The Terror of It 170

VII. In London, February, 1910 195

VIII. The Evacuation 231

IX. The Spectacle 274

X. Addendum 298
THE EVACUATION OF ENGLAND
CHAPTER I.
IN WASHINGTON, APRIL, 1909.

Alexander Leacraft was regarding with as much interest as his


constitutional lassitude permitted, the progress of a distinctly audible
altercation on Pennsylvania avenue, Washington, D. C. The
disputants had not felt it necessary, under the relaxing influences of
a premature spring, to interpose any screen of secrecy, such as a
less exposed position, or subdued voices, between themselves and
the news-mongering (and hungering, let it be added) proletariat of
our nation’s capital.
A small crowd, composed of the singular human compound
always pervasive and never to be avoided in Washington, which, in
that centre of political sensations, is made up of street loafers,
accidental tourists, perambulating babies, “niggers,” and
presumptive statesmen, enclosed this “argument”; and from his
elevated station, within the front parlor of the McKinley, Mr. Leacraft
was afforded a very excellent view of and an equally distinct hearing
of the disagreement and its principals.
The two disputants were themselves sufficiently contrasted in
appearance to have allured the casual passer-by to observe their
contrasted methods in debate. One—the taller—was a thin, angular
man with unnaturally long arms, a peculiar swaying habit of body, an
elongated visage, terminating in a short, stubby growth of whiskers,
and a sharp, crackling kind of voice, with unmistakable nasal faults.
He seemed to be a southern man modified by a few imitations of the
northern type.
He was addressing a bulky, rather disdainful man in a
checquered suit of clothes, who had advanced the season’s fashion
by assuming a straw hat, and whose rosy face, broad and typical
features, and yet not plethoric expansion of body, strong and
stalwart frame betokened much animal force, and reserved power of
action. He might have been a northern man. As Alexander Leacraft
looked at them, it was the southern man who was speaking, and his
uplifted arm, at regular intervals, rose and fell, as the palms of both
hands met in a cadence of corroborative whacks. It may interest the
reader to know that the particular time of this particular incident was
April, 1909.
“Let me tell you this, Mr. Tompkins,” drawled the southerner with
loquacious ease, the crackle and sharpness of his intonation
appearing as his excitement increased, “the necessities of our states
demand the Canal at whatever cost. It will be the avenue for an
export trade to the east, which will convert our stored powers of
production into gold, and it will react upon the whole country north
and south in a way that will make all previous prosperity look like
nothing. Our cotton mills have grown, our mineral resources have
been developed; Georgia and Alabama are to-day competing with
your shaft furnaces and steel mills for the trade of the railroads, and
builders; and for that matter we are building ourselves. We can
support a population ten times all we have to-day; our resources
have been just broached, but exhaustion is a thousand years away.
Our rival has been Cuba. She has robbed us of trade; she has put
our sugar plantations out of business; even her iron, which I will
admit is superior in quality, has scaled our profits on raw ingots, but
she can’t hold us down on cotton. Open up this canal, and we will
gather the riches of the Orient; our ships will fill it with unbroken
processions, and in the train of that commerce in cotton, every
section of the Union will furnish its contribution to swell the argosies
of trade. I tell you sir” and the excited speaker, conscious of an
admiring sympathy in the crowd around him, raised his voice into a
musical shout, in which the crackle was quite lost, “the commerce,
the mercantile integrity of these United States will be restored, and
American bottoms for American goods will be no longer a vain
aspiration; it will be a realized dream, an actual fact.”
He paused, as if the projectile force of his words had deprived
him of breath, and then at the momentary opportunity Mr. Tompkins,
in a clear and metallic voice, with a punctuative force of occasional
hesitation, undertook his friend’s refutation.
“I’m not contesting the fact, Mr. Snowden,” he said, “that the
opening of the Canal means a good deal to your portion of the
country. Does it mean as much to the rest of the country, and does it
mean so much to you for a long time. You mention cotton. Do you
know that the cotton cultivation of India and Egypt has increased
enormously, and that it is grown with cheaper labor than you can
command. You have made the negro acquainted with his value. You
have raised his expectations, you have thrust him into a hundred
avenues of occupation and every one of his new avocations adds a
shilling a day to the worth per man of the remainder, who stick to
field work and cultivate your cotton fields. The cotton of Egypt and
the cotton of India, I mean its manufactured forms, will go through
that canal to Asia and Japan and Polynesia just as surely as yours
will, and it’ll go cheaper. It is poorer cotton, I know, but that will not
effect the result.
“That isn’t all. Brazil and the Argentine Republic are growing
cotton, and they are doing well at it. Europe will take the raw stuff
from them and keep up her present predominance in that market
while she turns their cotton bolls into satinettes and ginghams for
the almond-eyes of Asia. The canal, breaking down a barrier of
separation between the two oceans, turns loose into the Pacific the
whole frenzied, greedy and capable cohorts of European
manufacture. It will make a common highway for Europe, and our
unbuilt clippers and tramp steamers will stay unbuilt, or unused, to
rot on their ways in the shipyards. The west coast will be
sidetracked, and our trunk railroads will cut down their schedules
and their dividends at the same time. Roosevelt put this canal
through, and your southern votes helped to elect him against his
protest, but brought to it by an overwhelming public sentiment that
applauded his power to chain or sterilize trusts; and he promised last
March to your southern rooters, at his inauguration, to see that
before his present new term was over, before 1913, the canal would
be opened, and perhaps he’ll make good.
“You southerners elected Roosevelt, and you have killed the
Democratic party. The new powers of growth of that party were
most likely to develop among you, but you shoved aside the
proffered offer of political supremacy, because you too had
surrendered to the idols of Mammon, and were willing to sell your
birth-right for a mess of pottage. Well! You’ve got the canal and
you’ve got Roosevelt, and let me tell you Mr. Snowden,” and the
restrained, almost nonchalant demeanor of Mr. Tompkins became
suddenly charged with electric earnestness, “you’ll get Hell, too.”
This admonitory expletive, uttered with a force that seemed to
impart to it a physical objectivity, caused the increasing circle of
auditors to retreat sensibly, and, without more consideration, giving
a glance of mute scorn at the flushed face of the southerner, the
speaker pressed his way through the little crowd, which, after a
moment’s suspension of judgment, seemed reluctant to let him
escape, and disappeared.
His opponent was distinctly chagrined. The wrinkled lines about
his peculiarly pleasant eyes, indicated his strained attention, and
were not altogether unrelated to a sudden muscular movement in
his clenched hands. His hopes, however, for some sort of forensic
gratification might have been sensibly raised as he discovered
himself the sole occupant of the small vacant spot on the side walk,
walled in by a human investiture, the first line of which was made up
of two pickaninnies, three newsboys, one rueful cur and some
impromptu mothers who had taken the family babies out for air and
recreation, but, overcome by the indigenous love of debate, had
forgotten their mission, and held their charges in various attitudes of
somnolence or furtive rebellion against the hedge of men behind
them.
It was evidently expected that the southern gentleman would
relieve his feelings, and it was also evident from a few ejaculations
hap-hazardly emitted from the concourse, that the majority of those
present was in his favor.
Mr. Snowden looked around him reflectively, and a sense of
personal dignity forced its way against the almost over-powering
impulse to appeal to popular approval, and convinced him that the
place and the audience were inopportune for any further discussion.
He could not, however, escape the demonstrated force of popular
expectancy, and, with a consenting smile, a shrug of his shoulders,
and with his hat raised above his head, swinging gently, he called
out “Three cheers for Teddy and the Canal.”
In an instant the group seized the invitation, and under the
cover, if it may be so violently symbolized, of the cloud of vocality,
his enthusiasm evoked, Mr. Snowden, like the fortuitous and
directive deities of the epics, vanished.
There remained an unsatisfied group to which more accessions
were quickly made, the whole movement evidently animated by
some emotion then predominant in the national capital. This group
broke up into little knots of talkers, and as the day was closing, no
urgency of business engagements and no immediate insistency of
domestic duties interfered with the easily elicited Washingtonian
tendency to settle, on the public curb, the vexed questions of state,
if not to enlighten Providence on the more abstruse functions of His
authority.
Alexander Leacraft willingly surrendered himself to the study of
this representative public Althing, and felt his exasperating torpor so
much overcome by a new curiosity as to make him not averse to
stepping out into the hall of the hotel, descending the steps into the
street, and engaging himself in the capacity of a rotational listener at
the various groups, sometimes not exceeding two men, who had
become vocally animated, and felt themselves called upon to supply
the deficiency of objurgation, so disagreeably emphasized by the
sudden departure of the northern and southern disputants.
The illuminative results of his ambulatory inspection, and his
own expostulations or inquiry, may be thus succinctly summarized.
Mr. Theodore Roosevelt, elected in his own behalf in 1905, as
president of the United States, after having served out the unexpired
term of William McKinley, who was assassinated in November, 1901,
and with whom he had been elected as vice president, had been
again re-elected in the fall of 1908, against his emphatic rejection, at
first, of a joint nomination of the Republican and Democratic parties.
The campaign, if campaign it could be called, had been one of the
most extraordinary ever recorded, and in its features of popular
clamor, the grotesque conflict of the personal repugnance of an
unwilling candidate nominated against his will, and in defiance of his
own repeated inhibitions to nominate him at all, because of his
solemn promise that he would defer to the unwritten law of the
country, and not serve a third term, was altogether unprecedented,
and to some observers ominous. He was reminded that his first
term, although practically four years, was still only an accident, that
there was no subversion of the unwritten law, in his serving again,
as his actual election as president had occurred but once, that his
popularity among the people was of such an intense, almost self-
devouring ardor, that it was an act of suicidal negation, of unpatriotic
desertion to shun or reject the people’s obvious need, that a war, yet
unfinished, had been begun by him against corporate interests, that
its logical continuance devolved upon him, that the unique occasion
of a unanimous nomination to the presidency carried with it a
sublime primacy of interest, that cancelled all previous conditions,
promises or wishes on his part, and laid an imperious command
upon its subject that deprived him of volition, and absolutely
dissolved into nothingness any apparent contradiction of his words
and acts. Finally, it was insisted that the Panama Canal was nearing
completion, that its remarkable advance was due to Mr. Roosevelt
that this fact had been prepotent in shaping the councils of southern
Democrats in proposing the, otherwise unwarranted, endorsement of
a Republican nomination, that a strong minority sentiment had
crystallized around an angry group of capitalists who were only too
anxious to get rid of Roosevelt altogether, and that in the case of his
refusal, these men would so manipulate the newspapers, and
inflame public apprehension, against some possible outbreak of
social radicalism, financial heresy, and anarchistic violence, that a
reaction begun would become unmanageable, and some tool of the
reactionaries, and the railroads, would be swept into office, and with
him a servile Congress, and Roosevelt’s work, so aggressively and
successfully prosecuted, would be all sacrificed. Nor was this all. The
return to a divided nomination, with an unmistakable intention on
the part of the conservatists to repeal all disadvantageous legislation
to the monopolies, corporations and trusts, would at once precipitate
a conflict of classes.
A radical man, possibly a demagogue, would be placed in
opposition to the choice of the plutocracy. His election was also not
improbable. The powers of socialism, enormously strengthened by
the adhesion of an educated class, might be triumphant, and the
succeeding steps in social revolution would bring chaos.
This dilemma was so pertinaciously displayed, so forcibly
accentuated, that Roosevelt had yielded at the last moment, not
insensibly affected (as what spirited man would not be) by the
magnificent assemblies (mass meetings) throughout the country,
tumultuously vociferating the call of the people.
The southern people, with characteristic warmth, and through
the suddenly consummated attachment of Senator Tillman to
Roosevelt, and under the coercion of Senator Bailey’s logic and
power of argumentative persuasion, had swelled the tide of popular
approval. Roosevelt became an idol—his election was almost
unanimous, a handful only of contestants having gathered in a kind
of moral protest around Governor Hughes as a rival candidate.
Governor Hughes’ nomination was achieved through a combination
of opposite political interests, as anomalous as that which chose
Roosevelt, and having precisely the same quality of coherence.
It represented dissatisfied Republicans, an alienable remnant of
Democrats, and had drawn into it a few sporadic political elements
that barely sufficed to give it numerical significance. W. J. Bryan,
who would have been otherwise a candidate himself, had endorsed
Roosevelt, furnishing thereby an example of political abnegation
which had enormously increased his popularity, and assured him the
nomination of Nationalists, as the new fusionists were called, in
1913. This was also deemed a wise forethought, as a provision
against the possible success of the rampant Hearstites. Hearst would
have been the socialist candidate in the last campaign, had not the
principal himself, on hearing of Roosevelt’s nomination, sapiently
withdrawn, fearing defeat, which would have too seriously
discredited him in the next national struggle.
The Prohibitionists had, by an act of virtual self-repudiation,
thrown their not inconsiderable vote to Roosevelt. The Socialists
were the only important opponents of his election, and their
surprising record made the prophetic warnings, which had convinced
Roosevelt of the necessity of his candidacy, appear like a veritable
intervention of Providence, at least this was the language commonly
used with reference to it.
Roosevelt had displayed remarkable self-control and consistent
gravity, and had even, in a very extraordinary address at his
inauguration, deprecated the unanimity of his election. He deplored
the precarious dilemma of a country which found itself forced to do
violence to its traditions in order to escape an imagined danger.
Almost synchronous with his re-election, the announcement had
been made that the Panama Canal, upon which the President in his
former term, had exerted the utmost pressure of his inexhaustible
enthusiasm, energy and exhortation, was advancing very rapidly,
engineering difficulties unexpectedly had vanished, a system of
extreme precision in the control of the work, itself largely the device
of the President, had facilitated the entire operation, and a promise
of still more rapid progress was made.
This promise had produced a storm of southern enthusiasm. The
south, completely restored in its financial autonomy, had been
growing richer and richer, and their public men had not hesitated to
paint, in the brightest colors, the further expansion of their
prosperity with the opening of this avenue of commerce between the
oceans, assuring its people the markets of Asia, and their rapid
promotion to the political, social and financial primacy in the United
States.
Northern capitalists had not been incredulous to these
predictions, and in a group of railroad magnates, whose interests
seemed now seriously threatened, a sullen resentment was
maintained against Roosevelt, in which the unmistakable notes of
designs almost criminal had been detected. Mr. Tompkins, whose
altercation with the southerner had led Leacraft into this voyage of
interpellation and discovery, was a paid agent, in the employ of this
cabal.
Alexander Leacraft was an Englishman, inheriting an English
temperament without English prejudices; he was fortunately free
from the worst faults of that insular hesitancy which imparts the
curious impression of timidity, and had advanced far enough in
cosmopolitan observation to get rid of the queerness of provincial
ignorance. He was indeed a sane and attractive man, and provided
by nature with a forcible physique, a good face, and a really
fascinating proclivity to make the best of things, admire his
companions, and bend unremittingly to the pressure of his
environment.
He had not escaped the dangers incident to youth, and his heart
had become attached to a lady of Baltimore—one of the
undeviatingly arch and winning American girls—to whom he had
been introduced by her brother, a commercial correspondent.
The nature of his affairs—he was the secretary of an English
company which operated some copper mines in Arizona and Canada
—had made him a frequent visitor to the shores of the New World,
and he had not been unwilling to express his hope that the United
States would become his final home. These sentiments were quite
honest, though it might have elicited the cynical observation that the
capture of his affections by Miss Garrett had done more to weaken
his loyalty to the crown than any dispassionate admiration of a
Republican form of government. But the imputation would have
been malicious. Leacraft did feel an earnest admiration for the
American people, and yielded a genial acquiescence to the claims of
popular suffrage. His connexion with America had been fortunate,
and he had come in contact with men and women whose natures by
endowment, and whose manners and habits, conversation and
tastes, by inheritance and cultivation, were elevating and engaging—
men and women whose nobility of sympathy with all things human
was reflected in an art of living not only always decorous and
refined, but guided, too, by the principles of urbanity and justice.
The Garretts of Baltimore were a widely connected, and in
numbers an imposing social element, and none of the various
daughters of light and loveliness who bore that name more merited
consideration in the eyes of manly youth than the capricious,
captivating and elusive Sally. Her graces of manner were not less
delightful than her conversation was spirited and roguish, and her
assumption of a demure simplicity had often driven Alexander
Leacraft to the limits of his English matter-of-fact credulity in
explaining to her the relations of the King to Parliament, or the
municipal acreage of the old City of London. All of which information
this very well read and much travelled young woman, as might be
expected, was possessed of, but just for the purposes of her
feminine and cruel fancy, not too well disposed towards her patient
suitor, disingenuously concealed. Sally really enjoyed the painstaking
gravity with which the young Englishman explained the eternal
principles of English rule, and the never-to-be-forgotten superiorities
of London.
Mr. Leacraft had met Sally under circumstances the most
provocative of admiration. In her own home; where the sincerity of
hospitality and the urgency of an American’s deference to the best
instincts of courtesy, did not altogether mitigate her coquetry and
mirthful affectations, and even, by the faintest gloss of repression,
made them the more delicious. The Englishman was bewitched, and
his infatuation declared itself so plainly that Sally—whose heart was
quite untouched by his distress—tried the resources of her ingenuity
to avoid meeting him alone.
Leacraft, on the morrow of the day, whose close had so deeply
inducted him into a study of American politics, expected to make a
deferred visit to the Garretts at Baltimore, and he had quite firmly
resolved that he would reveal his desperate extremity to Sally, and
plead his best to show her how empty life would be to him without
her, and that it would be shockingly obdurate in her to decline to
regard him as the goal of her marital ambitions.
He felt some fear of her revolting gayety, and his fears were not
assuaged by the remembrance of any particular occasion when her
conduct towards him permitted him to indulge in hopes. Still the
thing must be done. His unrest must be quieted. To know the worst
was better than this feverish anxiety of doubt. And besides, with a
prudence not altogether British, he thought he could endure repulse
better now than later, and in the event of that evil alternative, he
could cast about him for alleviating resources which might be more
easily found now, than if he waited longer, and if he continued to
expose himself to the perilous encounter of her eyes, and the
tantalizing caresses of her wit.
When Leacraft returned to the hotel, he found a letter waiting
for him, which he saw at once was from his friend, Ned Garrett. He
tore it open and discovered, to his considerable discomfiture, that it
postponed the event of his momentous proposal.
It read:

Dear Leacraft:
Aunt Sophia is very sick at Litchfield, Conn. Mother and Sally
have gone on. Can you put off your visit until May, say the 28th? You
will find it dull here without Sally and Mother. I shall go with them as
far as New York. We all intend, if Aunt Sophy concludes to remain in
this bright world a little longer, and the Dr. endorses her good
intentions, to visit Gettysburg on Memorial Day (Decoration old
style). The President will deliver a memorial oration. Come with us
and see the great battlefield, which is a wonderful monument to the
nation’s dead, a beautiful picture itself, and probably you will see
and hear things worth remembering besides. Write to the house,
and I will get your letter when I return in two weeks. But do come.
Yours sincerely,
Edward T. Garrett.

Leacraft put down the letter slowly. He was disappointed. A


summons to the west, to the mines in Arizona, had reached him just
the day before, and he must get out there before a week was over.
He had thought to have finished this affair first, and to find in the
tiresome trip distraction, if Sally was unfavorable to his appeal, or
unexpected interest if he succeeded in winning her assent. Still he
could readily accept the invitation. He would be back in May, and,
perhaps after all the occasion might be more favorable. Sally
softened into a little sympathetic humor by her visit to her sick aunt,
and he strengthened by the encouraging reflexion of having
successfully dissipated the little cloud of misunderstanding, or worse,
at the mines, might produce conditions psychologically adequate to
bring about his victory.
He stepped to the window. The view from it was always
pleasing, at this moment in the descending shades of the closing day
and with the vanishing lights hurrying westward beyond the
Potomac, it possessed an ineffable loveliness. The great white
spectre of the Washington monument, immaterialized and faintly
roseate against the softly flaming skies, and brooding genius-like
above the trees of the Reservation was always there, and that night
it assumed the strangely deceptive but fascinating vagary of an
exhalation, as if built up from the emanations of the earth, and the
vapors of the air, remaining immobile in the still ether as a portent or
a promise. The man’s face grew clouded as the fairy obelisk faded,
and with the enveloping darkness became again discernible as a dull
and stony pile.
That evening Leacraft felt particularly restless and detached. He
felt the need of entertainment, and of entertainment of a sort that
would fix his faculty of thought, awaken speculation, and immerse
him in reasonings and the intricacies of argument. The few theatrical
bills presented no attractions more weighty than a clever comedian
in a musical farce, a sensational melodrama (“much better,” said
Leacraft), and vaudeville. Music was shunned; there was nothing
quite serious offered, and then music has so many painful influences
on the apprehensive mind, and is turned to such cruel uses in the
economy of nature, for making uneasy lovers more agitated. No! he
didn’t wish music. Baffled for an instant, he concluded to walk.
Muscular exercise, mere translation on one’s legs, is a marvellous
remedy for the diabolical blues, and then it can never be told what
the Unseen holds for you, if you only go out to meet It in the
streets, and amongst other people, hunting, perhaps, like yourself,
diversion from their own inscrutable megrims. It—the Unseen—may
quite divertingly mix you up in a comedy or a tragedy, or consolingly
give you a glimpse of other human miseries immeasurably greater
than your own.
So walk it was. He had hardly covered two blocks towards the
White House, when he met Dr. M—, the most amiable and
accomplished editor of the National Museum, and one of those
multi-facetted gentlemen who respond to every scientific thrill
around them, and hold in the myriad piled up cells of their cerebral
cortex the knowledge, selected, labelled and accessible, of the
world. Leacraft knew the Doctor; had indeed consulted him upon a
chemical reaction, in the elimination of cadmium from zinc. The
Doctor, with genial fervor, grasped his hand, persuasively put his
own disengaged hand on Leacraft’s back, and dexterously turned
him around with the observation: “You are going the wrong way.
Binn reads a paper to-night before the Geographical Society, over at
the Museum, on a live subject. It’s about earthquakes and the
Panama Canal. The matter has a good deal of present interest. The
President may be there. It’s worth your while. Come along.”
Leacraft jumped with pleasure, if an Englishman may be said
ever to respond so animatedly to a welcome alternative. This met his
requirements exactly. He would, in these surroundings and under the
stimulation of an intellectual effort, in listening to a lecture which he
hoped might possess literary merit as well, quite forget his
immediate solicitudes.
“It is curious,” resumed Dr. M—, as they directed their steps
towards the umbrageous solitudes of the Reservation, “how
inevitably many practical questions demand an answer at the hand
of geology or physiography, which are however never consulted, and
disaster follows. In the spring of 1906 a destructive outbreak of
Vesuvius occurred, and much of the ensuing loss of life might have
been prevented by reliance upon scientific warnings. Indeed, the
loss of life on this last occasion of the volcano’s activity was greatly
reduced through the premonitions of its approach by delicate
instruments. For that matter, from the beginning, the vulcanologist,
at least as soon as such a being was a more or less completed
phenomenon in our scientific life, would have pointed out the
considerable risk of living on the flanks of that querulous
protuberance. But it can hardly be expected, I suppose, that large
populations can effect a change in habitation as long as the dangers
that threaten them occur at long intervals, and the human fatality of
unreasoning trust in luck remains unchanged. Take for instance the
case of the village of Torre del Greco, four and a half miles from the
foot of Vesuvius. It has been overwhelmed seventeen times, but the
inhabitants, the survivors, return after each extinction to renew their
futile invocations for another chance.”
“I suppose,” queried Leacraft, “that we are to be informed to-
night whether the Canal from the scientific point of view is a safe
investment?”
“Perhaps,” doubtfully returned the doctor. “You see, it’s this way.
In the spring of the year that saw the outpouring of lava that
invaded the villages of southern Italy, San Francisco suffered from a
serious earthquake that ruptured the public structures of the city,
dislocated miles of railroad tracks, ruined the beautiful Stanford
University, shook out the fronts of buildings, and precipitated a fire
that all but wiped out the Queen City of the Pacific coast. It has
been feared that some such seismic terror might demolish the
superb structures of the canal, and we are to learn to-night whether
these earth movements threaten the new waterway at the isthmus.”
“I have reason to believe,” rejoined Leacraft, “that this canal has
been itself a source of political disturbance, and that it is likely to
effect convulsions in your body politic as dangerous in a social way
as those which brought about the financial and physical upset at San
Francisco.”
“Don’t worry on that score,” replied his companion. “I can tell
you that the political texture of this country is not to be worn to a
frazzle by any collision of interests. Such things adjust themselves,
and the way out only means a new entrance to brighter prospects
and bigger undertakings. Yes, I guess someone will be hurt, but
individuals don’t count if the whole people are benefited.”
“Still,” remonstrated Leacraft, “the people is made up of
individuals, and it’s simply a fact that you can’t disturb the
equilibrium of one part of society without jostling the rest.”
“In a way, yes,” slowly answered the doctor. “But it is quite clear
to my mind that the enormous advantages of the canal will hide
from sight the losses that may be inflicted on the railroads, in the
dislocation of rates, and even that will be temporary, as the new
business raises our population, and their passenger traffic touches
higher and higher averages.”
“The canal has been an expensive enterprise,” suggested
Leacraft. “It would be a great misfortune if it brought any kind of
material reverses.”
“Rubbish,” retorted the doctor; “this prating is the madness or
the envy of croakers and cranks. Do you think that a connexion
between the oceans that will shorten the route from one to the other
by nearly 6,000 miles, and bring our eastern seaboard, with all its
tremendous agencies of production within reach of a continent that
is slowly becoming itself occidentalized, and demanding every day
the equipment of the west, is a mercantile delusion? We are all
gainers. It is a scheme of mutualization on a world-wide scale, but
America distributes the profits and holds the surplus.”
The two friends by this time had reached the entrance of the
Museum, and passing through its symbolic portals, turned to the left,
and found themselves in a dull room, portentously charged with an
exhaustive exhibit of the commerce of all nations. Here, on tables
and shelves, was displayed a wonderful assortment of primitive and
modern ships, primeval dugouts, Philippine catamarans,
Mediterranean pirogues, sloops, schooners, brigs, brigantines,
barques, barkentines, luggers, lighters, caravals, Dutch
monstrosities, models of those extraordinary ships which Motley has
described as “built up like a tower, both at stem and stern, and
presenting in their broad, bulbous prows their width of beam in
proportion to their length, their depression amidships, and in other
sins against symmetry, as much opposition to progress over the
waves as could well be imagined,” the Latin trireme and the Greek
trireme, the ironclads of France used in 1855, the monitors of the
Civil War, the recent wonders in battleships, torpedo boats, and
destroyers, with naphtha launches, submarine wonders, the old time
American cutters, and models of the stately packets that once made
the trip from New York to Portsmouth in fourteen days, with a
various and diversified exhibit of yachts and pleasure boats, all
burnished, japanned and varnished, and now dimly lustrous in the
futile illumination of the room. Above them on the walls was a prolix
illustration of the hydrography of the world; charts of currents,
pelagic streams, areas of calms, submarine basins, maps of rainfalls,
prevalent winds, storm regions, precipitation, barometric maxima
and minima, and then still higher up on the walls, that dispensed
knowledge over each square inch of their dusty and dusky surfaces,
Leacraft descried the tabulations of tonnage of the merchant marine
of the nations of the earth, with fabulous figures of imports and
exports, and the staple products of this prolific and motherly old
earth, caressed into fructification by the tireless arms of her
scrambling broods of children.
Leacraft was soon deserted by the doctor, who found occasion to
wander among the slowly arriving scientific gentry and politely
inquire after the health of the particular scientific offspring, whose
tottering footsteps each one was engaged in nurturing into a more
reliant attitude before the world. Leacraft found the dim room, with
its preoccupied occupants vacantly settling into the seats around
him, and its motley array of picturesque models strangely congenial.
It soothed, by the abrupt strangeness of its contents, the subdued
intellectual placidity of the audience, and by its mere physical
retirement from the outer bustle of the streets, and the iterative
commonplaces of the hotel corridor. The exact process of subduction
would have been hard keenly to analyze, but Leacraft seemed to
forget his personal disquietude, and develop into a congenital
oneness with these earnest men and women around him, eager to
know, and not too patient towards sophistry or pretension. He hardly
cared to know who was who. It made no matter. They all seemed
freed from the petty vanities of living, and now engrossed in the
triumphant tasks of thought; and he felt himself elevated into a kind
of mental abstraction which eagerly carried on its functions in an
atmosphere of ideas.
And yet how was it, that just above the little desk which was to
receive the honorable burden of the lecturer’s manuscript, he
suddenly distinctly saw the fair face, with its light blue eyes, its
delicate blush of color, and the slightly mocking pout of the lips of
Sally, the beloved. Leacraft almost rose upright in his astonishment
at the impossible hallucination. He was leaning forward, half
incredulous of the report of his own senses, and half subjected by a
delicious whim that the apparition was an augury of success, when a
commotion spreading on all sides of him roused his attention, and
the vision fled. He would have willingly had it stay. People were
rising in his vicinity, and soon the assembly was on its feet. Some
one had entered who was the cause of this unusual excitement.
“The President” came to his ears, murmured by a dozen persons
near him, and he had hardly sprung to his own feet when, with
many salutations, a strongly formed, rather bulky man, with a
manner of almost nervous scrutiny passed by him moving down the
aisle to the front. It was indeed President Roosevelt, and Leacraft,
now startled into the most active interest, slipped forward a seat or
two, to gain a position which might afford him a better view of this
remarkable person. The audience remained standing until the
President, escorted by a tall red-whiskered gentleman, whom Doctor
M—, who had just turned up in search of his friend, whispered was
Dr. George O. Smith, the distinguished Director of the Survey, had
reached a seat reserved for him at the front of the hall.
Leacraft now observed more closely the character of the
convocation, and realized its composite and representative elements.
Dr. M—, always himself immersed in the study of the lives,
achievements and distinctions of the prominent men of the country,
was an enthusiastic verbal cicerone through the maze of faces which
seemed suddenly to have condensed into a really crowded audience.
Here was Dr. D—, the Alaskan explorer in the early days of the
nineteenth century, the world recognized authority on the tertiary
fossils of the east and west coasts, and a man of erudition and
delightful literary skill. Beyond him sat Dr. M—, a quiet-faced man,
curator of the National Museum, author of text books, and gifted
with a singularly shrewd thoughtfulness. At his side sat the sphinx-
featured F—, of Chicago, a gentle-minded scholar, to whom the
Heavens had entrusted the secrets of their meteoritic denizens, and
who, by a more fortunate circumstance, held a pen of consummate
grace. Again at his side was the Jupiter-browed Ward, an erratic
over the face of the globe, possessed with a transcendant
enthusiasm for the same celestial visitors that F— described, and
chasing them with the zeal of a lynx in their most inaccessible
quarries; a man of immense conviviality, and controlling the
smouldering fires of a temper that defied reason or resistance. At
the front of the rows of chairs, and not far from the cynosure of all
eyes—the President—were two notable students of the past life of
the globe, Professors O— and S—, men whose studies in that
amazing storehouse of extinct life which the West held sealed in its
clays and marls, limestones and sandstones, had continued on
higher and more certain levels the work of Marsh and Leidy and
Cope, and who had transcribed before the whole world, in
monuments of scientific precision, the most startling confessions of
the fossil dead. To one side, on the same row, sat Prof. B—, known
in two continents, for chemical learning, especially on that side of
chemistry which mingles insensibly with the laws of matter. And
whispering in his ear, with sundry emphatic nods, sat, next to him,
Dr. R—, of Washington, learned in the ways of men’s digestion, and
the enigmas of food and the arts of food-makers. In the row behind,
the expressive head of Young, aureoled with years and honors, was
seen, and at his side the face of Newcomb, who had set the seal of
his genius and industry across the patterned stars. Here was A— H
—, the geologist, reticent and receptive, there C—, weighted with
new responsibilities in furnishing time to the rapacious biologist, and
in discovering new ways of making this old world. Behind them sat M
—, wise beyond belief in bric-a-brac and brachiopods, vindictively
assertive, and self-sacrificingly tender and kind. There was McG—
and I—, W—, A—, V—, and B— W—, bringing to the speaker the
homage of archæology, of petrology, of zoology, and morphology. In
a group of motionless and eager attention were A—, the sage
metereologist, beloved in two continents; B—, abstruse and difficult,
meditative, as a man might be who kept his hand on the pulses of
matter, and B—, skillful in weighing the atoms of the air, or probing
the volcanoes of the moon. In one line, mingling in conversation that
reached Leacraft’s ears as a strange jargon of conflicting sciences,
were G—, H— and H—k. And beyond them, mute, as if by mutual
repulsion, sat F—, the agile scrutinizer of Nature’s crystals; P—,
holding in his labyrinthine memory the names of half a universe of
shells, and B—n, to whom each plant of the wayside bowed in
recognition of a master’s knowledge of itself. Against the wall, in a
triad of sympathy, was A—, the surgeon; S—, the neurologist, and R
—. And alone, in an isolation that belied his intense geniality, was K
—.

You might also like