100% found this document useful (1 vote)
143 views

Fundamentals of Python: First Programs, 2nd Edition Kenneth A. Lambert 2024 Scribd Download

First

Uploaded by

akotojsoto16
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
143 views

Fundamentals of Python: First Programs, 2nd Edition Kenneth A. Lambert 2024 Scribd Download

First

Uploaded by

akotojsoto16
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Download the full version of the ebook at

https://ebookmass.com

Fundamentals of Python: First Programs, 2nd


Edition Kenneth A. Lambert

https://ebookmass.com/product/fundamentals-of-
python-first-programs-2nd-edition-kenneth-a-
lambert/

Explore and download more ebook at https://ebookmass.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Fundamentals Of Python: Data Structures 2nd Edition


Kenneth A. Lambert

https://ebookmass.com/product/fundamentals-of-python-data-
structures-2nd-edition-kenneth-a-lambert/

testbankdeal.com

Data Science from Scratch: First Principles with Python


2nd Edition

https://ebookmass.com/product/data-science-from-scratch-first-
principles-with-python-2nd-edition/

testbankdeal.com

Fundamentals of Structural Analysis 5th Edition Kenneth M.


Leet

https://ebookmass.com/product/fundamentals-of-structural-analysis-5th-
edition-kenneth-m-leet/

testbankdeal.com

Python Fundamentals for Finance: A survey of Algorithmic


Options trading with Python Van Der Post

https://ebookmass.com/product/python-fundamentals-for-finance-a-
survey-of-algorithmic-options-trading-with-python-van-der-post/

testbankdeal.com
C and Python Applications: Embedding Python Code in C
Programs, SQL Methods, and Python Sockets Philip Joyce

https://ebookmass.com/product/c-and-python-applications-embedding-
python-code-in-c-programs-sql-methods-and-python-sockets-philip-joyce/

testbankdeal.com

Fundamentals of Structural Analysis Solution Manual 5th


edition Kenneth M. Leet

https://ebookmass.com/product/fundamentals-of-structural-analysis-
solution-manual-5th-edition-kenneth-m-leet/

testbankdeal.com

Fundamentals of Nursing 2nd Edition Lauren Mctier

https://ebookmass.com/product/fundamentals-of-nursing-2nd-edition-
lauren-mctier/

testbankdeal.com

Essentials of Anatomy & Physiology, 2nd Edition Kenneth S.


Saladin

https://ebookmass.com/product/essentials-of-anatomy-physiology-2nd-
edition-kenneth-s-saladin/

testbankdeal.com

A Beginners Guide to Python 3 Programming 2nd Edition John


Hunt

https://ebookmass.com/product/a-beginners-guide-to-
python-3-programming-2nd-edition-john-hunt/

testbankdeal.com
Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
second Edition

Fundamentals of Python:
First Programs

Kenneth A. Lambert

Martin Osborne,
Contributing Author

Australia • Brazil • Mexico • Singapore • United Kingdom • United States

Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.

Important Notice: Media content referenced within the product description or the product
text may not be available in the eBook version.

Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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: © 2019, 2012 Cengage
First Programs, Second Edition
ALL RIGHTS RESERVED. No part of this work covered by the copy-
­Kenneth A. Lambert
right herein may be reproduced or distributed in any form or by
any means, except as permitted by U.S. copyright law, without the
SVP, GM Skills: Jonathan Lau prior written permission of the copyright owner.

Product Team Manager: Kristin Unless otherwise noted all tables/figures exhibits are © 2019 ­Cengage®
McNary

Associate Product Manager: Kate


For product information and technology assistance, contact us
Mason
at Cengage Customer & Sales Support, 1-800-354-9706
Executive Director of Development:
Marah Bellegarde For permission to use material from this text or product, submit
all requests online at www.cengage.com/permissions.
Senior Content Development Further permissions questions can be e-mailed to
­Manager: Leigh Hefferon permissionrequest@cengage.com

Content Development Manager: Jill


Gallagher
Library of Congress Control Number: 2017952738
Senior Content Developer: Natalie
Pashoukos
Softbound ISBN: 978-1-337-56009-2
Product Assistant: Jake Toth Loose Leaf ISBN: 978-1-337-69934-1

Marketing Director: Michele McTighe Cengage


20 Channel Center Street
Marketing Manager: Stephanie Boston, MA, 02210
Albracht
USA
Senior Content Project Manager:
Cengage is a leading provider of customized learning solutions with
Jennifer Feltri-George
employees residing in nearly 40 different countries and sales in more
Senior Designer/Art Director: Diana than 125 countries around the world. Find your local representative
Graham at www.cengage.com.

Cover image: Digital_Art/­ Cengage products are represented in Canada by Nelson Education, Ltd.
Shutterstock.com To learn more about Cengage, visit www.cengage.com.
Production Service/Composition: Purchase any of our products at your local college store or at our
SPi Global ­preferred online store www.cengagebrain.com.

Notice to the Reader

Publisher does not warrant or guarantee any of the products described herein or perform any independent analysis
in connection with any of the product information contained herein. Publisher does not assume, and expressly
disclaims, any obligation to obtain and include information other than that provided to it by the manufacturer. The
reader is expressly warned to consider and adopt all safety precautions that might be indicated by the activities
described herein and to avoid all potential hazards. By following the instructions contained herein, the reader willingly
assumes all risks in connection with such instructions. The publisher makes no representations or warranties of any
kind, including but not limited to, the warranties of fitness for particular purpose or merchantability, nor are any
such representations implied with respect to the material set forth herein, and the publisher takes no responsibility
with respect to such material. The publisher shall not be liable for any special, consequential, or exemplary damages
resulting, in whole or part, from the readers’ use of, or reliance upon, this material.

Printed in the United States of America


Print Number: 01 Print Year: 2017
Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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
iii

Pref ace ������������������������������������������������ xiii

CHAPTER 1 I n t ro du ct io n����������������������������������������������� 1
Two Fundamental Ideas of Computer Science: ­
Algorithms and Information Processing ������������������������������ 2
Algorithms ������������������������������������������������������������������� 2
Information Processing��������������������������������������������������� 4
Exercises ������������������������������������������������������������������������ 5
The Structure of a Modern Computer System������������������������ 6
Computer Hardware ������������������������������������������������������� 6
Computer Software ������������������������������������������������������� 7
Exercises ������������������������������������������������������������������������ 9
A Not-So-Brief History of Computing Systems������������������������ 9
Before Electronic Digital Computers��������������������������������11
The First Electronic Digital Computers (1940–1950) ���������13
The First Programming Languages (1950–1965) ��������������14
Integrated Circuits, Interaction,
and Timesharing (1965–1975)��������������������������������������16
Personal Computing and Networks (1975–1990) ��������������17
Consultation, Communication,
and E-Commerce (1990–2000)��������������������������������������19
Mobile Applications and Ubiquitous
Computing (2000–present) ������������������������������������������21
Getting Started with Python Programming ���������������������������22
Running Code in the Interactive Shell ������������������������������22
Input, Processing, and Output�����������������������������������������24
Editing, Saving, and Running a Script ������������������������������27
Behind the Scenes: How Python Works�����������������������������28
Exercises �����������������������������������������������������������������������29
Detecting and Correcting Syntax Errors������������������������������29
Exercises �����������������������������������������������������������������������30
Suggestions for Further Reading ���������������������������������������30
Summary �����������������������������������������������������������������������31

Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
contents

Review Questions ������������������������������������������������������������32


Projects��������������������������������������������������������������������������33

CHAPTER 2 S o f t w are D
­ evelo pment, Data Ty pes,
iv an d Expres s io n s��������������������������������������� 34
The Software Development Process �����������������������������������35
Exercises �����������������������������������������������������������������������37
Case Study: Income Tax Calculator ������������������������������������38
Strings, Assignment, and Comments�����������������������������������41
Data Types ������������������������������������������������������������������41
String Literals��������������������������������������������������������������42
Escape Sequences��������������������������������������������������������43
String Concatenation�����������������������������������������������������43
Variables and the Assignment Statement��������������������������44
Program Comments and Docstrings ��������������������������������45
Exercises �����������������������������������������������������������������������46
Numeric Data Types and Character Sets �����������������������������47
Integers�����������������������������������������������������������������������47
Floating-Point Numbers��������������������������������������������������47
Character Sets ������������������������������������������������������������48
Exercises �����������������������������������������������������������������������49
Expressions��������������������������������������������������������������������49
Arithmetic Expressions��������������������������������������������������50
Mixed-Mode Arithmetic and Type Conversions��������������������52
Exercises �����������������������������������������������������������������������53
Using Functions and Modules ��������������������������������������������54
Calling Functions: Arguments and Return Values ���������������54
The math Module ���������������������������������������������������������55
The Main Module�����������������������������������������������������������56
Program Format and Structure ���������������������������������������57
Running a Script from a Terminal Command Prompt�����������57
Exercises �����������������������������������������������������������������������59
Summary �����������������������������������������������������������������������59
Review Questions ������������������������������������������������������������61
Projects��������������������������������������������������������������������������62

CHAPTER 3 Lo o ps an d S elec ti on S tatements������������������ 64


Definite Iteration: The for Loop�����������������������������������������65
Executing a Statement a Given Number of Times ��������������65
Count-Controlled Loops��������������������������������������������������66
Augmented Assignment��������������������������������������������������67
Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
contents

Loop Errors: Off-by-One Error�����������������������������������������68


Traversing the Contents of a Data Sequence ��������������������68
Specifying the Steps in the Range�����������������������������������69
Loops That Count Down ������������������������������������������������69
Exercises �����������������������������������������������������������������������70
Formatting Text for Output������������������������������������������������70 v
Exercises �����������������������������������������������������������������������72
Case Study: An Investment Report��������������������������������������73
Selection: if and if-else Statements ������������������������������77
The Boolean Type, Comparisons, and Boolean
Expressions ���������������������������������������������������������������77
if-else Statements�����������������������������������������������������78
One-Way Selection Statements ���������������������������������������79
Multi-Way if Statements �����������������������������������������������80
Logical Operators and Compound Boolean Expressions �����82
Short-Circuit Evaluation��������������������������������������������������84
Testing Selection Statements �����������������������������������������84
Exercises �����������������������������������������������������������������������85
Conditional Iteration: The while Loop ��������������������������������86
The Structure and Behavior of a while Loop��������������������86
Count Control with a while Loop������������������������������������87
The while True Loop and the break Statement���������������88
Random Numbers ���������������������������������������������������������90
Loop Logic, Errors, and Testing��������������������������������������91
Exercises �����������������������������������������������������������������������92
Case Study: Approximating Square Roots ���������������������������92
Summary �����������������������������������������������������������������������96
Review Questions ������������������������������������������������������������97
Projects��������������������������������������������������������������������������99

CHAPTER 4 S t r in g s an d Text Fi l es ����������������������������� 102


Accessing Characters and Substrings in Strings ��������������� 103
The Structure of Strings ��������������������������������������������� 103
The Subscript Operator����������������������������������������������� 104
Slicing for Substrings ������������������������������������������������ 105
Testing for a Substring with the in Operator ����������������� 105
Exercises �������������������������������������������������������������������� 106
Data Encryption ����������������������������������������������������������� 106
Exercises �������������������������������������������������������������������� 109
Strings and Number Systems ����������������������������������������� 109
The Positional System for Representing Numbers����������� 110
Converting Binary to Decimal �������������������������������������� 111
Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
contents

Converting Decimal to Binary �������������������������������������� 112


Conversion Shortcuts ������������������������������������������������ 112
Octal and Hexadecimal Numbers ��������������������������������� 113
Exercises �������������������������������������������������������������������� 114
String Methods ������������������������������������������������������������ 115
vi Exercises �������������������������������������������������������������������� 118
Text Files �������������������������������������������������������������������� 118
Text Files and Their Format����������������������������������������� 118
Writing Text to a File �������������������������������������������������� 119
Writing Numbers to a File�������������������������������������������� 119
Reading Text from a File ��������������������������������������������� 120
Reading Numbers from a File �������������������������������������� 121
Accessing and Manipulating Files and Directories
on Disk ������������������������������������������������������������������ 122
Exercises �������������������������������������������������������������������� 125
Case Study: Text Analysis����������������������������������������������� 126
Summary �������������������������������������������������������������������� 130
Review Questions ��������������������������������������������������������� 131
Projects����������������������������������������������������������������������� 132

CHAPTER 5 Lis t s an d Dict io nari es ����������������������������� 134


Lists �������������������������������������������������������������������������� 135
List Literals and Basic Operators��������������������������������� 135
Replacing an Element in a List ������������������������������������ 138
List Methods for Inserting and Removing Elements��������� 138
Searching a List �������������������������������������������������������� 140
Sorting a List ����������������������������������������������������������� 140
Mutator Methods and the Value None ��������������������������� 141
Aliasing and Side Effects �������������������������������������������� 141
Equality: Object Identity and Structural
Equivalence ������������������������������������������������������������ 143
Example: Using a List to Find the Median
of a Set of Numbers ������������������������������������������������ 143
Tuples ��������������������������������������������������������������������� 144
Exercises �������������������������������������������������������������������� 145
Defining Simple Functions ��������������������������������������������� 146
The Syntax of Simple Function Definitions ��������������������� 146
Parameters and Arguments����������������������������������������� 147
The return Statement����������������������������������������������� 147
Boolean Functions ����������������������������������������������������� 148
Defining a main Function �������������������������������������������� 148
Exercises �������������������������������������������������������������������� 149
Case Study: Generating Sentences ��������������������������������� 150
Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
contents

Dictionaries ����������������������������������������������������������������� 153


Dictionary Literals ����������������������������������������������������� 153
Adding Keys and Replacing Values�������������������������������� 154
Accessing Values ������������������������������������������������������ 154
Removing Keys ��������������������������������������������������������� 155
Traversing a Dictionary����������������������������������������������� 155 vii
Example: The Hexadecimal System Revisited����������������� 156
Example: Finding the Mode of a List of Values ��������������� 157
Exercises �������������������������������������������������������������������� 158
Case Study: Nondirective Psychotherapy�������������������������� 159
Summary �������������������������������������������������������������������� 163
Review Questions ��������������������������������������������������������� 164
Projects����������������������������������������������������������������������� 165

CHAPTER 6 Des ig n w it h F u ncti ons ����������������������������� 167


A Quick Review of What Functions Are and How
They Work ����������������������������������������������������������������� 168
Functions as Abstraction Mechanisms �������������������������� 169
Functions Eliminate Redundancy����������������������������������� 169
Functions Hide Complexity ������������������������������������������ 170
Functions Support General Methods with Systematic
Variations ��������������������������������������������������������������� 170
Functions Support the Division of Labor ����������������������� 171
Exercises �������������������������������������������������������������������� 171
Problem Solving with Top-Down Design����������������������������� 172
The Design of the Text-Analysis Program����������������������� 172
The Design of the Sentence-Generator Program�������������� 173
The Design of the Doctor Program�������������������������������� 174
Exercises �������������������������������������������������������������������� 176
Design with Recursive Functions�������������������������������������� 176
Defining a Recursive Function�������������������������������������� 176
Tracing a Recursive Function �������������������������������������� 177
Using Recursive Definitions to Construct Recursive
Functions ��������������������������������������������������������������� 178
Recursion in Sentence Structure����������������������������������� 179
Infinite Recursion ������������������������������������������������������ 179
The Costs and Benefits of Recursion����������������������������� 180
Exercises �������������������������������������������������������������������� 182
Case Study: Gathering Information from a File System�������� 183
Managing a Program’s Namespace ��������������������������������� 190
Module Variables, Parameters, and Temporary
Variables����������������������������������������������������������������� 190
Scope ��������������������������������������������������������������������� 191
Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
Visit https://ebookmass.com
now to explore a rich
collection of eBooks and enjoy
exciting offers!
contents

Lifetime�������������������������������������������������������������������� 192
Using Keywords for Default and Optional Arguments�������� 193
Exercises �������������������������������������������������������������������� 194
Higher-Order Functions�������������������������������������������������� 195
Functions as First-Class Data Objects��������������������������� 195
viii Mapping�������������������������������������������������������������������� 196
Filtering�������������������������������������������������������������������� 197
Reducing ����������������������������������������������������������������� 197
Using lambda to Create Anonymous Functions �������������� 198
Creating Jump Tables�������������������������������������������������� 199
Exercises �������������������������������������������������������������������� 199
Summary �������������������������������������������������������������������� 200
Review Questions ��������������������������������������������������������� 202
Projects����������������������������������������������������������������������� 203

CHAPTER 7 S im ple Gr aph ics and Image Processi ng ������� 205


Simple Graphics����������������������������������������������������������� 206
Overview of Turtle Graphics����������������������������������������� 206
Turtle Operations ������������������������������������������������������ 207
Setting Up a turtle.cfg File and Running IDLE����������������� 209
Object Instantiation and the turtle Module ������������������ 210
Drawing Two-Dimensional Shapes �������������������������������� 212
Examining an Object’s Attributes ��������������������������������� 213
Manipulating a Turtle’s Screen�������������������������������������� 214
Taking a Random Walk ���������������������������������������������� 214
Colors and the RGB System����������������������������������������� 215
Example: Filling Radial Patterns with Random
Colors�������������������������������������������������������������������� 216
Exercises �������������������������������������������������������������������� 218
Case Study: Recursive Patterns in Fractals����������������������� 218
Image Processing �������������������������������������������������������� 222
Analog and Digital Information�������������������������������������� 223
Sampling and Digitizing Images ����������������������������������� 223
Image File Formats����������������������������������������������������� 224
Image-Manipulation Operations ������������������������������������ 224
The Properties of Images�������������������������������������������� 225
The images Module ��������������������������������������������������� 225
A Loop Pattern for Traversing a Grid����������������������������� 228
A Word on Tuples ������������������������������������������������������ 229
Converting an Image to Black and White ����������������������� 230
Converting an Image to Grayscale�������������������������������� 231
Copying an Image ����������������������������������������������������� 232
Blurring an Image ������������������������������������������������������ 233
Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
contents

Edge Detection ��������������������������������������������������������� 234


Reducing the Image Size �������������������������������������������� 235
Exercises �������������������������������������������������������������������� 237
Summary �������������������������������������������������������������������� 237
Review Questions ��������������������������������������������������������� 238
Projects����������������������������������������������������������������������� 240 ix

CHAPTER 8 G r aph ical Us er Inter faces ������������������������� 244


The Behavior of Terminal-Based Programs and ­GUI-Based
Programs ������������������������������������������������������������������ 245
The Terminal-Based Version����������������������������������������� 246
The GUI-Based Version ����������������������������������������������� 246
Event-Driven Programming ������������������������������������������ 248
Exercises �������������������������������������������������������������������� 249
Coding Simple GUI-Based Programs �������������������������������� 249
A Simple “Hello World” Program����������������������������������� 249
A Template for All GUI Programs����������������������������������� 251
The Syntax of Class and Method Definitions ������������������ 251
Subclassing and Inheritance as Abstraction
Mechanisms ����������������������������������������������������������� 252
Exercises �������������������������������������������������������������������� 253
Windows and Window Components����������������������������������� 253
Windows and Their Attributes �������������������������������������� 253
Window Layout����������������������������������������������������������� 254
Types of Window Components and Their Attributes��������� 256
Displaying Images ����������������������������������������������������� 257
Exercises �������������������������������������������������������������������� 259
Command Buttons and Responding to Events�������������������� 260
Exercises �������������������������������������������������������������������� 262
Input and Output with Entry Fields����������������������������������� 262
Text Fields ��������������������������������������������������������������� 262
Integer and Float Fields for Numeric Data ��������������������� 264
Using Pop-Up Message Boxes�������������������������������������� 265
Exercises �������������������������������������������������������������������� 267
Defining and Using Instance Variables ����������������������������� 267
Exercises �������������������������������������������������������������������� 269
Case Study: The Guessing Game Revisited����������������������� 269
Other Useful GUI Resources�������������������������������������������� 273
Using Nested Frames to Organize Components�������������� 273
Multi-Line Text Areas �������������������������������������������������� 275
File Dialogs �������������������������������������������������������������� 277
Obtaining Input with Prompter Boxes����������������������������� 280
Check Buttons����������������������������������������������������������� 281
Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
contents

Radio Buttons ����������������������������������������������������������� 282


Keyboard Events�������������������������������������������������������� 284
Working with Colors��������������������������������������������������� 285
Using a Color Chooser ����������������������������������������������� 287
Summary �������������������������������������������������������������������� 289
x Review Questions ��������������������������������������������������������� 289
Projects����������������������������������������������������������������������� 290

CHAPTER 9 Des ig n w it h Clas ses �������������������������������� 293


Getting Inside Objects and Classes ��������������������������������� 294
A First Example: The Student Class����������������������������� 295
Docstrings ��������������������������������������������������������������� 297
Method Definitions����������������������������������������������������� 297
The __init __ Method and Instance Variables����������������� 298
The __str __ Method �������������������������������������������������� 299
Accessors and Mutators��������������������������������������������� 299
The Lifetime of Objects����������������������������������������������� 299
Rules of Thumb for Defining a Simple Class ������������������ 300
Exercises �������������������������������������������������������������������� 301
Case Study: Playing the Game of Craps��������������������������� 301
Data-Modeling Examples������������������������������������������������ 309
Rational Numbers ������������������������������������������������������ 309
Rational Number Arithmetic and Operator Overloading����� 311
Comparison Methods�������������������������������������������������� 312
Equality and the __eq__ Method����������������������������������� 313
Savings Accounts and Class Variables �������������������������� 314
Putting the Accounts into a Bank ��������������������������������� 317
Using pickle for Permanent Storage of Objects����������� 319
Input of Objects and the try-except Statement����������� 320
Playing Cards ����������������������������������������������������������� 321
Exercises �������������������������������������������������������������������� 324
Case Study: An ATM ����������������������������������������������������� 324
Building a New Data Structure: The Two-Dimensional Grid �� 330
The Interface of the Grid Class����������������������������������� 330
The Implementation of the Grid Class: Instance
Variables for the Data����������������������������������������������� 332
The Implementation of the Grid Class: Subscript
and Search�������������������������������������������������������������� 333
Case Study: Data Encryption with a Block Cipher �������������� 333
Structuring Classes with Inheritance and Polymorphism ����� 337
Inheritance Hierarchies and Modeling ��������������������������� 338
Example 1: A Restricted Savings Account ��������������������� 339
Example 2: The Dealer and a Player in the Game
ofRights
Copyright 2019 Cengage Learning. All Blackjack������������������������������������������������������������ 340
Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
contents

Polymorphic Methods������������������������������������������������� 344


The Costs and Benefits of Object-Oriented
Programming����������������������������������������������������������� 345
Exercises �������������������������������������������������������������������� 346
Summary �������������������������������������������������������������������� 347
Review Questions ��������������������������������������������������������� 348 xi
Projects����������������������������������������������������������������������� 349

CHAPTER 10 M u lt it h readin g , ­Networks, and Cl i ent/ Serv er


Pro g r am m in g ���������������������������������������� 352
Threads and Processes�������������������������������������������������� 353
Threads�������������������������������������������������������������������� 354
Sleeping Threads ������������������������������������������������������ 357
Producer, Consumer, and Synchronization �������������������� 358
Exercises �������������������������������������������������������������������� 364
The Readers and Writers Problem ����������������������������������� 364
Using the SharedCell Class �������������������������������������� 365
Implementing the Interface of the SharedCell Class ����� 366
Implementing the Helper Methods of the
SharedCell Class �������������������������������������������������� 368
Testing the SharedCell Class with a Counter Object ����� 369
Defining a Thread-Safe Class �������������������������������������� 370
Exercises �������������������������������������������������������������������� 371
Networks, Clients, and Servers �������������������������������������� 371
IP Addresses ������������������������������������������������������������ 372
Ports, Servers, and Clients ����������������������������������������� 373
Sockets and a Day/Time Client Script �������������������������� 373
A Day/Time Server Script�������������������������������������������� 375
A Two-Way Chat Script ����������������������������������������������� 377
Handling Multiple Clients Concurrently �������������������������� 378
Exercises �������������������������������������������������������������������� 380
Case Study: Setting Up Conversations between Doctors
and Patients �������������������������������������������������������������� 381
Summary �������������������������������������������������������������������� 386
Review Questions ��������������������������������������������������������� 387
Projects����������������������������������������������������������������������� 388

CHAPTER 11 S earch in g , ­So r ti ng, and Compl ex i ty Anal y si s� 390


Measuring the Efficiency of Algorithms����������������������������� 391
Measuring the Run Time of an Algorithm ����������������������� 391
Counting Instructions�������������������������������������������������� 394
Exercises
Copyright 2019 Cengage Learning. ��������������������������������������������������������������������
All Rights Reserved. 396
May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
contents

Complexity Analysis ������������������������������������������������������ 397


Orders of Complexity�������������������������������������������������� 397
Big-O Notation����������������������������������������������������������� 399
The Role of the Constant of Proportionality�������������������� 400
Measuring the Memory Used by an Algorithm����������������� 400
xii Exercises �������������������������������������������������������������������� 401
Search Algorithms �������������������������������������������������������� 401
Search for a Minimum ������������������������������������������������ 401
Sequential Search of a List ����������������������������������������� 402
Best-Case, Worst-Case, and Average-Case
Performance����������������������������������������������������������� 403
Binary Search of a List����������������������������������������������� 403
Exercises �������������������������������������������������������������������� 405
Basic Sort Algorithms ��������������������������������������������������� 405
Selection Sort����������������������������������������������������������� 406
Bubble Sort �������������������������������������������������������������� 407
Insertion Sort ����������������������������������������������������������� 408
Best-Case, Worst-Case, and Average-Case
Performance Revisited ��������������������������������������������� 410
Exercises �������������������������������������������������������������������� 410
Faster Sorting�������������������������������������������������������������� 411
Quicksort ����������������������������������������������������������������� 411
Merge Sort��������������������������������������������������������������� 415
Exercises �������������������������������������������������������������������� 418
An Exponential Algorithm: Recursive Fibonacci ����������������� 419
Converting Fibonacci to a Linear Algorithm����������������������� 420
Case Study: An Algorithm Profiler ����������������������������������� 421
Summary �������������������������������������������������������������������� 427
Review Questions ��������������������������������������������������������� 428
Projects����������������������������������������������������������������������� 429

APP ENDIX A Pyt h o n Res o u rce s ���������������������������������� 432

APP ENDIX B In s t allin g t h e i mages


an d br ee zy py th ongui Li brari es �������������� 434

APP ENDIX C T h e API f o r Im age Processi ng������������������� 436

APP ENDIX D Tr an s it io n f ro m Py thon to Jav a and C++ ����� 438

Glo s s ar y ���������������������������������������������� 439

In dex ���������������������������������������������������� 455


Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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
xiii

“Everyone should learn how to code.” That’s my favorite quote from Suzanne Keen, the
Thomas Broadus Professor of English and Dean of the College at Washington and Lee Uni-
versity, where I have taught computer science for more than 30 years. The quote also states
the reason why I wrote the first edition of Fundamentals of Python: First Programs, and why
I now offer you this second edition. The book is intended for an introductory course in pro-
gramming and problem solving. It covers the material taught in a typical Computer Science 1
course (CS1) at the undergraduate or high school level.
This book covers five major aspects of computing:
1. Programming Basics—Data types, control structures, algorithm development, and
program design with functions are basic ideas that you need to master in order to
solve problems with computers. This book examines 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 dic-
tionaries. This book introduces you to these commonly used data structures and
includes examples that illustrate criteria for selecting the appropriate data struc-
tures 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 pro-
gramming and problem solving is to create interesting programs with real-world
applications. In this book, you’ll begin by creating applications that involve numeri-
cal 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

Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
P r e f a c e Why Python?

one does not restrict itself to problems involving numbers and text. Most contem-
porary applications involve graphical user interfaces, event-driven programming,
graphics, image manipulation, and network communications. These topics are not
consigned to the margins, but are presented in depth after you have mastered the
basics of programming.
xiv

Why Python?
Computer technology and applications have become increasingly more sophisticated over
the past three decades, and so has the computer science curriculum, especially at the intro-
ductory level. Today’s students learn a bit of programming and problem solving, and they
are then expected to move quickly into topics like software development, complexity analy-
sis, and data structures that, 30 years ago, were relegated to advanced courses. In addition,
the ascent of object-oriented programming as the dominant paradigm of problem solving
has led instructors and textbook authors to implant powerful, industrial-strength program-
ming languages such as C++ and Java in the introductory curriculum. As a result, instead
of experiencing the rewards and excitement of solving problems with computers, beginning
computer science students often become overwhelmed by the combined tasks of mastering
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
studying 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 conventional notation found in
algebra. Thus, students can spend less time learning the syntax of a programming lan-
guage 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 programming 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 interpret-
er’s prompts to allow the programmer to try out experimental code and receive immedi-
ate 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 computing 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 community, and expertise in
Python programming has great résumé value.

Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
Organization of the Book pr e f a c e

To summarize these benefits, Python is a comfortable and flexible vehicle for expressing
ideas about computation, both for beginners and for experts. If students learn these ideas
well in the first course, they should have no problems making a quick transition to other
languages needed for courses later in the curriculum. Most importantly, beginning students
will spend less time staring at a computer screen and more time thinking about interesting
problems to solve. xv

Organization of the Book


The approach of this text is easygoing, with each new concept introduced only when it is
needed.
Chapter 1 introduces computer science by focusing on two fundamental ideas, algorithms
and information processing. A brief overview of computer hardware and software, followed
by an extended discussion of the history of computing, sets the context for computational
problem solving.
Chapters 2 and 3 cover the basics of problem solving and algorithm development using the
standard control structures of expression evaluation, sequencing, Boolean logic, selection,
and iteration with the basic numeric data types. Emphasis in these chapters is on problem
solving that is both systematic and experimental, involving algorithm design, testing, and
documentation.
Chapters 4 and 5 introduce the use of the strings, text files, lists, and dictionaries. These
data structures are both remarkably easy to manipulate in Python and support some inter-
esting applications. Chapter 5 also introduces simple function definitions as a way of orga-
nizing algorithmic code.
Chapter 6 explores the technique and benefits of procedural abstraction with function
definitions. Top-down design, stepwise refinement, and recursive design with functions are
examined as means of structuring code to solve complex problems. Details of namespace
organization (parameters, temporary variables, and module variables) and communica-
tion among software components are discussed. A section on functional programming
with higher-order functions shows how to exploit functional design patterns to simplify
solutions.
Chapter 7 focuses on the use of existing objects and classes to compose programs. ­Special
attention is paid to the application programming interface (API), or set of methods, of
a class of objects and the manner in which objects cooperate to solve problems. This
­chapter also introduces two contemporary applications of computing, graphics and
image ­processing—areas in which object-based programming is particularly useful.
Chapter 8 introduces the definition of new classes to construct graphical user interfaces
(GUIs). The chapter contrasts the event-driven model of GUI programs with the process-
driven model of terminal-based programs. The creation and layout of GUI components
are explored, as well as the design of GUI-based applications using the model/view pattern.
The initial approach to defining new classes in this chapter is unusual for an introductory

Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
P r e f a c e Special Features

textbook: students learn that the easiest way to define a new class is to customize an exist-
ing class using subclassing and inheritance.
Chapter 9 continues the exploration of object-oriented design with the definition of entirely
new classes. Several examples of simple class definitions from different application domains
are presented. Some of these are then integrated into more realistic applications, to show
xvi how object-oriented software components can be used to build complex systems. Emphasis
is on designing appropriate interfaces for classes that exploit polymorphism.
Chapter 10 covers advanced material related to several important areas of computing:
concurrent programming, networks, and client/server applications. This chapter thus
gives students challenging experiences near the end of the first course. Chapter 10 intro-
duces multithreaded programs and the construction of simple network-based client/server
applications.
Chapter 11 covers some topics addressed at the beginning of a traditional CS2 course. This
chapter introduces complexity analysis with big-O notation. Enough material is presented
to enable you to perform simple analyses of the running time and memory usage of algo-
rithms and data structures, using search and sort algorithms as examples.

Special Features
This book explains and develops concepts carefully, using frequent examples and diagrams.
New concepts are then applied in complete programs to show how they aid in solving prob-
lems. The chapters place an early and consistent emphasis on good writing habits and neat,
readable documentation.
The book includes several other important features:
•• Case studies—These present complete Python programs ranging from the simple to
the substantial. To emphasize the importance and usefulness of the software develop-
ment life cycle, case studies are discussed in the framework of a user request, followed
by analysis, design, implementation, and suggestions for testing, with well-defined tasks
performed at each stage. Some case studies are extended in end-of-chapter program-
ming projects.
•• Chapter objectives and chapter summaries—Each chapter begins with a set of learning
objectives and ends with a summary of the major concepts covered in the chapter.
•• Key terms and a glossary—When a technical term is introduced in the text, it appears in
boldface. Definitions of the key terms are also collected in a glossary.
•• Exercises—Most major sections of each chapter end with exercise questions that rein-
force the reading by asking basic questions about the material in the section. Each chap-
ter ends with a set of review exercises.
•• Programming projects—Each chapter ends with a set of programming projects of vary-
ing difficulty.

Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
Visit https://ebookmass.com
now to explore a rich
collection of eBooks and enjoy
exciting offers!
Instructor Resources pr e f a c e

•• A software toolkit for image processing—This book comes with an open-source


Python toolkit for the easy image processing discussed in Chapter 7. The toolkit can be
obtained from the student downloads page on www.cengage.com, or at http://home.wlu
.edu/~lambertk/python/
•• A software toolkit for GUI programming—This book comes with an open-source
Python toolkit for the easy GUI programming introduced in Chapter 8. The toolkit can xvii
be obtained from the student downloads page on www.cengage.com, or at http://home
.wlu.edu/~lambertk/breezypythongui/
•• Appendices—Four appendices include information on obtaining Python resources,
installing the toolkits, and using the toolkits’ interfaces.

New in This Edition


The most obvious change in this edition is the addition of full color. All program examples
include the color coding used in Python’s IDLE, so students can easily identify program
elements such as keywords, program comments, and function, method, and class names.
Several new figures have been added to illustrate concepts, and many exercises and pro-
gramming projects have been reworked. The brief history of computing in Chapter 1 has
been brought up to date. A discussion of a Grid type has been included to give students
exposure to a two-dimensional data structure. The book remains the only introductory
Python text with a thorough introduction to realistic GUI programming. The chapter
on GUIs (Chapter 8) now uses the breezypythongui toolkit to ease the introduction of
this topic. The chapter on GUIs has also been placed ahead of the chapter on design with
classes (Chapter 9). This arrangement allows students to explore the customizing of exist-
ing classes with GUI programming before they tackle the design of entirely new classes in
the following chapter. Finally, a new section on the readers and writers problem has been
added to Chapter 10, to illustrate thread-safe access to shared resources.

Instructor Resources
MindTap
MindTap activities for Fundamentals of Python: First Programs are designed to help stu-
dents master the skills they need in today’s workforce. Research shows employers need
critical thinkers, troubleshooters, and creative problem-solvers to stay relevant in our
fast-paced, technology-driven world. MindTap helps you achieve this with assignments
and activities that provide hands-on practice and real-life relevance. Students are guided
through assignments that help them master basic knowledge and understanding before
moving on to more challenging problems.
All MindTap activities and assignments are tied to defined unit learning objectives.
­Hands-on coding labs provide real-life application and practice. Readings and dynamic
visualizations support the lecture, while a post-course assessment measures exactly how

Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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.
P r e f a c e We Appreciate Your Feedback

much a student has learned. MindTap provides the analytics and reporting to easily see
where the class stands in terms of progress, engagement, and completion rates. Use the
content and learning path as-is or pick-and-choose how our materials will wrap around
yours. You control what the students see and when they see it. Learn more at http://www
.cengage.com/mindtap/.
xviii

Instructor Companion Site


The following teaching tools are available for download at the Companion Site for this text.
Simply search for this text at www.cengagebrain.com and choose "Instructor Downloads."
An instructor login is required.
•• Instructor’s Manual: The Instructor’s Manual that accompanies this textbook includes
additional instructional material to assist in class preparation, including items such as
Overviews, Chapter Objectives, Teaching Tips, Quick Quizzes, Class Discussion Top-
ics, Additional Projects, Additional Resources, and Key Terms. A sample syllabus is also
available.
•• Test Bank: Cengage Testing Powered by Cognero is a flexible, online system that allows
you to:
•• author, edit, and manage test bank content from multiple Cengage solutions
•• create multiple test versions in an instant
•• deliver tests from your LMS, your classroom, or wherever you want
•• PowerPoint Presentations: This text provides PowerPoint slides to accompany each
chapter. Slides may be used to guide classroom presentations, to make available to stu-
dents for chapter review, or to print as classroom handouts. Files are provided for every
figure in the text. Instructors may use the files to customize PowerPoint slides, illustrate
quizzes, or create handouts.
•• Solutions: Solutions to all programming exercises are available. If an input file is
needed to run a programming exercise, it is included with the solution file.
•• Source Code: The source code is available at www.cengagebrain.com. If an input file is
needed to run a program, it is included with the source code.

We Appreciate Your Feedback


We have tried to produce a high-quality text, but should you encounter any errors,
please report them to lambertk@wlu.edu or http://support.cengage.com. A list of errata,
should they be found, as well as other information about the book, will be posted on
the Web site http://home.wlu.edu/~lambertk/python/ and with the student resources at
www.cengagebrain.com.

Copyright 2019 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2019 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:
therefore take our leave of St. Francis, whose procession was in the
day time: but I must tell you it is only to inform you of another of a
much more awful and shocking nature, which I saw afterwards at
night. About ten o’clock, being deeply engaged in conversation with
my kind host, in came an Englishman, and told me in all haste, that
he had seen a train of near two hundred penitents passing along,
and that in all probability I might be gratified with the same sight, if I
hastened to a place whither he would conduct me. I very readily
obeyed the summons, and, as curiosity quickened my pace, we soon
came up with some of those poor creatures, who were then making
a halt, and kneeling in the street, whilst a friar from a high cross, with
an image of our Lord crucified in his hand, was preaching to them
and the populace with great vehemence. Sermon being ended, the
penitents went forwards, and several companies followed after with
their respective preaching friars at their head, bearing crucifixes.
These they pointed to and brandished frequently, and the hearers as
frequently beat their breasts, and clapped their cheeks. At proper
pauses they stopped and prayed, and one of them, more zealous
than the rest, before the King’s palace, sounded the word penitentia
through a speaking trumpet. The penitents themselves were clothed
and covered all over with white linen vestments, only holes were
made for their eyes to peep out at. All were bare-footed, and all had
long heavy chains fastened to their ancles, which, when dragged
along the street, made a dismal rattling: but though alike in dress, yet
in other respects there was great variety amongst them. For some
carried great stones on their backs, and others dead mens bones
and skulls in their hands. Some bore large and seemingly very heavy
crosses upon their shoulders, whilst others had their arms extended
quite wide, or carried a bow full of swords with the points
downwards. Most of them whipped and lashed themselves, some
with cords, and others with flat bits of iron. It being a moonshine
night, I could see them quite well; and indeed some of them struck
so hard, that I perceived their backs (left bare on purpose to be
slashed) were quite red, and swoln very much by the violence and
repetition of the blows. Had my dear friend been there, he would
have joined with me in saying, that the whole scene was horrible;—
so horrible, that, being informed it was to be continued till morning, I
was glad to return from whence I came about midnight.――Had you
been with me, I know you would have joined with me in praising and
gratefully adoring the Lord of all lords, for the great wonder of the
reformation, and also for that glorious deliverance wrought out for us
a few years past, in defeating the unnatural rebellion. O what a
mighty spirit and power from on high must Luther, Calvin,
Melancthon, Zuinglius, and those glorious reformers, be necessarily
endued with, who dared first openly to oppose and stem such a
torrent of superstition and spiritual tyranny! and what gratitude owe
we to those, who, under God, were instrumental in saving us from
the return of such spiritual slavery, and such blind obedience to a
papal power! To have had a papist for our king;—a papist, if not
born, yet from his infancy nursed up at Rome;—a papist, one of
whose sons is advanced to the ecclesiastical dignity of a Cardinal,
and both under the strongest obligations to support the interest of
that church, whose superstitions, as well as political state principles,
they have sucked in, and imbibed even from their infancy. But,
blessed be God, the snare is broken, and we are delivered. O for
protestant practices to be added to protestant principles! O for an
obediential acknowledgment to the ever-blessed God for our
repeated deliverances! But alas!――Pardon me, my dear friend, I
stop to weep. Adieu. I cannot enlarge, but leaving you to guess from
what source my tears flow, I must hasten to subscribe myself, my
dear Sir,

Yours most cordially in our blessed Lord,

G. W.

LETTER MXXXVII.
To Mr. B――.

Lisbon, April 9, 1754.


Reverend and dear Sir,

T HE time of our departure hence is just at hand. I cannot move


without sending you a few lines; I remember your unmerited
love, I remember our affectionate parting, and I trust feel the benefit
of your distant prayers. Though called to part with what is dearer to
me than life, yet my heavenly Father hath not left me comfortless.
True, it is a silent, but I hope an instructive period of life. One must
be all eye and ear at Lisbon:—and indeed, I would not but have seen
and heard what hath passed here, since our arrival, upon any
account. It surpasseth all description. Surely England, and English
privileges civil and religious, will be dearer to me than ever. The
preachers here have also taught me something; their action is
graceful. Vividi oculi,—vividæ manus,—omnia vivida. Surely our
English preachers would do well, to be a little more fervent in their
address. They have truth on their side, why should superstition and
falshood run away with all that is pathetic and affecting? But my dear
friend needs not this note. Blessed be God for making you fervent in
spirit. Go on, my dear Sir, in the name and strength of Jesus.
Sequar, etsi non passibus æquis.—Nil desperandum Christo duce.
Pray remember me to all that love him, and are so kind as to enquire
after a worthless worm for his great name’s sake. It will be an act of
the greatest charity to intercede in my behalf. Alas! alas! I am a
dwarf indeed. My dear Sir, pray that I may grow, I cannot bear to live
at this dying rate. I want to be a flame of fire. That this may be your
happy lot, is and shall be, through Christ strengthening me, the
earnest request of, my very dear Sir,

Your most unworthy, though affectionate friend, brother, and


fellow-labourer in our common Lord,

G. W.

LETTER MXXXVIII.
To Mrs. G――.

Lisbon, April 9, 1754.

Dear Madam,

I HOPE this will find you more than happy, in the enjoyment of Him,
whose death and passion many at this season are peculiarly
called upon to remember, and be thankful for. Vast are the outward
preparations made here. Altars upon altars are erecting. Penitents
upon penitents are walking and lashing themselves: but what I want
to have erected and adorned, is an altar in my heart, and the blows
and lashes I desire to feel, are the crucifixion and mortification of the
old man and its deeds. Without this, all is mere parade. God be
praised for opening your eyes, and teaching you the holy art of
worshipping him in spirit and in truth. Is it not a glorious privilege?
Would you lose it for ten thousand worlds? Blessed be God, it is in
safe hands! The life of a believer is a hidden life; a life hid with
Christ in God. May the Author and Finisher thereof, cause it to
open and be displayed more and more every hour and every
moment in your heart! Thus prays, dear Madam,

Your most obliged and ready servant for Christ’s sake,

G. W.

LETTER MXXXIX.
To Mr. H――.

Lisbon, April 10, 1754.

My very dear Friend,


TILL I am here, surrounded with every thing, in an ecclesiastical way,
that can offend a mind which desires to worship the Lord
S Jesus in outward as well as inward simplicity. To-morrow is
what they call Holy Thursday. May I be as solicitous to have
my heart illuminated by the spirit of God, as the people here are to
illuminate their churches and altars. The pageantry is indeed
incredible. Though we have been detained longer than expectation,
yet I trust what I have seen and heard, will do me service in the
future part of my life. Was I returning to, as I am going from England,
and had I a proper companion, I would make a tour to Leghorn,
Genoa, Rome, &c. and so to Marseilles. What instruction would such
a mind as yours gather from such various scenes? O that I may be
like a busy bee, and suck some honey even from superstitious
flowers! I do not wonder now, whence the illuminations, dressing of
altars, and those other things which I have lately mentioned in a
public manner on another occasion, took their birth. It is all in
imitation of what is daily practised abroad. May the Lord Jesus
crush the cockatrice in its egg, and prevent its growing any bigger! I
write this from a merchant’s house, who sent for me from on board.
Thus our Lord provides for those that are employed for him. Help
me to praise him. My fatherless charge are all well. In a day or two
we expect to sail. My most cordial respects attend your mother, and
all your dear relations. Continue to pray for me, and thereby add to
the obligations already conferred on, my very dear friend,

Yours most affectionately in our common Lord,

G. W.

LETTER MXL.
Lisbon, April 12, 1754.

My dear Friend,
P ROVIDENCE still detains us at Lisbon, and therefore I know you
will be enquiring what more news from thence?—Truly, as
extraordinary as ever—for I have now seen the solemnities of an
Holy-Thursday, which is a very high day in this metropolis, and
particularly remarkable for the grand illuminations of the churches,
and the king’s washing twelve poor men’s feet.—Through the
interest of a friend, I got admittance into the gallery where the
ceremony was performed. It was large, and hung with tapestry; one
piece of which represented the humble Jesus washing the feet of his
disciples.—Before this, upon a small eminence, sat twelve men in
black. At the upper end, and in several other parts of the gallery,
were side-boards of large gold and silver basons and ewers most
curiously wrought; and near these a large table covered with a
variety of dishes, all cold, set off and garnished after the Portuguese
fashion. Public high mass being over, his majesty came in attended
with his nobles, who seemed to me to look like so many Roman
senators. The act of washing the feet, I did not get in time enough to
see; but that being ended, several of the young noblemen served up
the dishes to the king’s brother and uncles; these again handed
them to his majesty, who gave (I think) twelve of them in all to each
poor man. Every thing was carried on with a great deal of decency
and good humour. The young noblemen served very chearfully, their
seniors looked quite pleased, and the king and his royal relations
behaved in a very polite, easy manner,—upon the whole, though as
you may easily guess it was not an exact copy of the tapestry, yet,
as the poor mens cloaths and food, when sold, came to about ten
moidores; and as there was little mixture of superstition in it, I cannot
say but I was as well pleased with my morning’s entertainment as
with any thing I had seen since my arrival.—I believe the whole took
up near two hours. After dinner we went to see the churches; but the
♦magnificence and sumptuousness of the furniture, cannot well be
expressed.—Many of them were hung on the occasion with purple
damask trimmed with gold.—In one of them there was a solid silver
altar of several yards circumference, and near twelve steps high: and
in another a gold one, still more magnificent, of about the same
dimensions.—Its basis was studded with many precious stones, and
near the top were placed silver images, in representation of angels.
Each step was filled with large silver candlesticks, with wax-tapers in
them, which going up by a regular ascent, ’till they formed
themselves into a pyramid, made a most glittering and splendid
blaze.—The great altars also of the other churches were illuminated
most profusely, and silver pots of artificial flowers, with a large wax-
taper between each, were fixed all round several of them.—Between
these, were large paintings in black and white, representing the
different parts of our Saviour’s passion. And, in short, all was so
magnificently, so superstitiously grand, that I am persuaded several
thousands of pounds would not defray the expences of this one day.
Go which way you would, nothing was to be seen but illuminations
within, and hurry without.—For all persons, princes and crowned
heads themselves not excepted, are obliged on this day to visit
seven churches or altars, in imitation, as is supposed, of our Lord’s
being hurried from one tribunal to another, before he was
condemned to be hung upon the cross.—I saw the queen pass by in
great state to visit three of them. Velvet cushions were carried before
her Majesty, and boards laid along the streets for herself and retinue
to walk upon. Guards attended before and behind, and thousands of
spectators stood on each side to gaze at them as they passed along.
Being desirous of seeing the manner of their entrance, we got into
the last church before they came. It was that of St. Domingo, where
was the gold altar before mentioned, and at which her Majesty and
train knelt about a quarter of an hour.—All the while, the Dominican
friars sung most surprisingly sweet. But as I stood near the altar,
over against the great door, I must confess my very inmost soul was
struck with a secret horror, when, upon looking up, I saw over the
front of the great window of the church, the heads of many hundred
Jews, painted on canvas, who had been condemned by what they
call the Holy Inquisition, and carried out from that church to be burnt.
—Strange way this, of compelling people to come in! Such was not
thy method, O meek and compassionate Lamb of God! Thou camest
not to destroy mens lives, but to save them.—But bigotry is as cruel
as the grave.—It knows no remorse.—From all its bitter and dire
effects, good Lord deliver us!—But to return to the Queen. Having
performed her devotions, she departed and went in a coach of state,
I believe, directly from the church to her palace, and without doubt
sufficiently fatigued: for, besides walking through the streets to the
several churches, her Majesty also, and the princesses, had been
engaged in waiting upon, and washing the feet of twelve poor
women, in as public a manner as the king. In our walk home, we met
his Majesty with his brother and two uncles, attended only with a few
noblemen in black velvet, and a few guards without halberts. I
suppose he was returning from his last church, and, as one may well
imagine, equally fatigued with his royal consort and daughters.—
When church and state thus combine to be nursing fathers and
nursing mothers to superstition, is it any wonder that its credit and
influence is so diffusive among the populace?—O Britain! Britain!
hast thou but zeal proportionable to thy knowledge, and inward purity
adequate to the simplicity of thy external worship, in what a happy
and god-like situation wouldst thou be! Here I could weep again.—
Again I leave you to guess the cause; and if I can send you one
more letter of a like nature, before we leave this place, it is all you
must expect from, my dear friend,

Your’s most assuredly in our glorious Head,

G. W.

♦ “magnifience” replaced with “magnificence”


LETTER MXLI.
To Mr. ――.

Lisbon, April 12, 1755.

My dear Friend,

A FTER the news already sent you, I thought our Lisbon


correspondence would entirely have been put a stop to; for upon
returning to my lodgings, (as weary I believe as others that had been
running from church to church all day) word was sent me, that our ship
would certainly sail the next morning. This news, I own, was not
altogether agreeable to me, because I wanted to see the conclusion of
the Lent solemnities. However, I made ready; and having dispatched
my private affairs the over-night, was conducted very early in the
morning, by my kind host, down to Bellem, where the ship lay. We
parted. The wind promised to be fair; but dying away, I very eagerly
went ashore once more. But how was the scene changed! Before, all
used to be noise and hurry;—now, all was hushed and shut up in the
most awful and profound silence. No clock or bell had been heard
since yesterday noon, and scarce a person was to be seen in the
street all the way to Lisbon. About two in the afternoon we got to the
place, where (I had heard some days ago) an extraordinary scene was
to be exhibited. Can you guess what it was?—Perhaps not. Why then I
will tell you. “It was the crucifixion of the Son of God, represented
partly by dumb images, and partly by living persons, in a large church
belonging to the convent of St. De Beato.” Several thousands crouded
into it; some of whom, as I was told, had been waiting there from even
six in the morning.—Through the kind interposition and assistance of a
protestant or two, I was not only admitted into the church, but was very
commodiously situated to view the whole performance. We had not
waited long before the curtain was drawn up. Immediately, upon a high
scaffold hung in the front with black bays, and behind with silk purple
damask laced with gold, was exhibited to our view an image of the
Lord Jesus at full length, crowned with thorns, and nailed on a cross
between two figures of like dimensions, representing the two thieves.
At a little distance on the right hand, was placed an image of the virgin
Mary, in plain long ruffles, and a kind of widow-weeds. Her veil was
purple silk, and she had a wire glory round her head.—At the foot of
the cross lay, in a mournful pensive posture, a living man, dressed in
woman’s cloaths, who personated Mary Magdalen; and not far off
stood a young man, in imitation of the beloved disciple.—He was
dressed in a loose green silk vesture, and bob-wig.—His eyes were
fixed on the cross, and his two hands a little extended. On each side,
near the front of the stage, stood two centinels in buff, with formidable
caps and long beards; and directly in the front stood another yet more
formidable, with a large target in his hand. We may suppose him to be
the Roman centurion. To compleat the scene, from behind the purple
hangings came out about twenty little purple-vested winged boys, two
by two, each bearing a lighted wax-taper in his hand, and a crimson
and gold cap on his head.—At their entrance upon the stage, they
gently bowed their heads to the spectators, then kneeled and made
obeisance, first to the image on the cross, and then to that of the virgin
Mary.—When risen, they bowed to each other, and then took their
respective places over-against one another, on steps assigned for
them at the front of the stage. Opposite to this, at a few yards
distance, stood a black friar in a pulpit hung in mourning. For a while
he paused, and then, breaking silence, gradually lifted up his voice ’till
it was extended to a pretty high pitch, though I think scarce high
enough for so large an auditory. After he had proceeded in his
discourse about a quarter of an hour, a confused noise was heard
near the front great door; upon turning my head, I saw four long-
bearded men, two of which carried a ladder on their shoulders, and
after them followed two more with large gilt dishes in their hands, full
of linen, spices, &c. These (as I imagined) were the representatives of
Nicodemus and Joseph of Arimathea. On a signal given from the
pulpit, they advanced towards the steps of the scaffold. But upon their
very first attempting to mount it, at the watchful centurion’s nod, the
observant soldiers made a pass at them, and presented the points of
their javelins directly to their breasts. They are repulsed. Upon this a
letter from Pilate is produced. The centurion reads it, shakes his head,
and with looks that bespoke a forced compliance, beckons to the
centinels to withdraw their arms. Leave being thus obtained, they
ascend; and having paid their homage, by kneeling first to the image
on the cross, and then to the virgin Mary, they retired to the back of
the stage. Still the preacher continued declaiming, or rather (as was
said) explaining the mournful scene. Magdalen persists in wringing her
hands, and variously expressing her personated sorrow; whilst John
(seemingly regardless of all besides) stood gazing on the crucified
figure. By this time it was near three o’clock, and therefore proper for
the scene to begin to close. The ladders are ascended, the
superscription and crown of thorns taken off, long white rollers put
round the arms of the image, and then the nails knocked out which
fastened the hands and feet. Here Mary Magdalen looks most
languishing, and John, if possible, stands more thunder-struck than
before.—The orator lifts up his voice, and almost all the hearers
expressed concern by weeping, beating their breasts, and smiting
their cheeks.—At length the body is gently let down. Magdalen eyes it,
and, gradually rising, receives the feet into her wide-spread
handkerchief; whilst John (who hitherto stood motionless like a statue)
as the body came nearer the ground, with an eagerness that bespoke
the intense affection of a sympathizing friend, runs towards the cross,
seizes the upper part of it into his clasping arms, and, with his
disguised fellow-mourner, helps to bear it away. And here the play
should end, was I not afraid you would be angry with me, if I did not
give you an account of the last act, by telling you what became of the
corpse after it was taken down. Great preparations were made for its
interment. It was wrapped in linen and spices, &c. and being laid upon
a bier richly hung, was afterwards carried round the church-yard in
grand procession. The image of the virgin Mary was chief mourner,
and John and Magdalen, with a whole troop of friars with wax-tapers in
their hands, followed after. Determined to see the whole, I waited its
return, and in about a quarter of an hour the corps was brought in, and
deposited in an open sepulchre prepared for the purpose; but not
before a priest, accompanied by several of the same order in splendid
vestments, had perfumed it with incense, sung to and kneeled before
it. John and Magdalen attended the obsequies; but the image of the
virgin Mary was carried away and placed upon the front of the stage,
in order to be kissed, adored, and worshipped by the people.—This I
saw them do with the utmost eagerness and reverence. And thus
ended this Good Friday’s tragi-comical, superstitious, idolatrous farce.
A farce, which whilst I saw, as well as now whilst I am describing it,
excited in me an high indignation.—Surely, thought I, whilst attending
on such a scene of mock devotion, if ever, now is the dear Lord
Jesus crucified afresh; and I could then, and even now, think of no
other plea for the poor beguiled devotees, than that which suffering
innocence put up himself for his enemies, when actually hanging upon
the cross, “Father, forgive them, for they know not what they do.”
There was but one thing wanting to raise one’s resentment to the
highest pitch, and that was, for one of the soldiers to have pierced the
side of the image upon the cross. This in all probability you have heard
hath actually been done in other places, and with a little more art,
might, I think, have been performed here. Doubtless it would have
afforded the preacher as good, if not a better opportunity of working
upon the passions of his auditory, than the taking down the
superscription and crown of thorns, and wiping the head with a
blooded cloth, and afterwards exposing it to the view of the people; all
which I saw done before the body was let down.—But alas! my dear
friend, how mean is that eloquence, and how entirely destitute of the
demonstration of the spirit, and of a divine power, must that oratory
necessarily be, that stands in need of such a train of superstitious
pageantry to render it impressive!—Think you, my dear friend, that the
apostle Paul used or needed any such artifices to excite the passions
of the people of Galatia, amongst whom, as he himself informs us,
“Jesus Christ was crucified, and evidently set forth?”—But thus it is,
and thus it will be, when simplicity and spirituality are banished from
our religious offices, and artifice and idolatry seated in their room.—I
am well aware that the Romanists deny the charge of idolatry; but
after having seen what I have seen this day, as well as at sundry other
times since my arrival here, I cannot help thinking but a person must
be capable of making more than metaphysical distinctions, and deal in
very abstract ideas indeed, fairly to evade the charge.—If weighed in
the balance of the sanctuary, I am positive the scale must turn on the
protestant side.—But such a balance these poor people are not
permitted to make use of! Doth not your heart bleed for them? Mine
doth I am sure, and I believe would do so more and more, was I to
stay longer, and see what they call their Hallelujah, and grand
devotions on Easter-day.—But that scene is denied me.—The wind is
fair, and I must away.—Follow me with your prayers, and believe me to
be, my dear friend,

Yours most affectionately, in our common Redeemer,

G. W.

LETTER MXLII.
To Mrs. D――.

On board the Success, May 10, 1754.

My dear sister in Christ,

I T really hath given me much concern since I have been on the


mighty waters, that it was not in my power to write to you more
frequently when on shore. I therefore send you a few lines from the
great deep, which I hope will find you magnifying the Lord, and
rejoicing in God your Saviour. For his great name’s sake, I am once
more going to Georgia, and after a short tour through some parts of
America, I hope to see my native country, and begin to begin to ramble
after poor sinners again. In our way we touched at Lisbon, which I
hope hath been blessed to me, so far as to make me prize protestant
liberty and simplicity more than ever. Fain would I be one of Christ’s
bees, and learn to extract honey from every flower. But alas! I am a
drone, and deserve to be stung out of God’s hive. But he is gracious
and long suffering. O eternity! How do I long to praise my God there!
We are within a few hundred miles of our earthly, but when I shall
arrive at my heavenly port God only knows. Strange! that I should be
kept out at sea so long. I am now near forty. Father, thy will be done!
Only vouchsafe to employ me, and then――I can no more. The
Redeemer is pleased to fill my soul. Help me to cry Grace! Grace! and
believe me to be,
Your most assured friend, and ready servant, for Christ’s
sake,

G. W.

LETTER MXLIII.
To Mrs. S――.

On board the Success, May 12, 1754.

Dear Mrs. S――,

I FULLY purposed to have written to you from Lisbon, but was so


taken up in seeing the ecclesiastical curiosities of the place, and
was so suddenly called away, that rendered it impracticable.—
However, that I may not be disappointed again, I sit down to write you
a few lines, though about eight hundred miles off shore. May they find
you as to spirituals, in the same situation as is our ship in a natural
respect, gently, sweetly gliding towards your heavenly harbour, under
a pleasant gale of divine influence. Or,

If rough and stormy be your way,

Fear not―― Only to Jesus cry, and say,

Be strength proportion’d to my day.

You will find him a kind and faithful Saviour. Whom he loves, he loves
to the end. He hath already delivered you out of the paw of the bear
and of the lion, and he will also deliver out of the hand of every
remaining Goliah. Courage, then, my dear Mrs. S――, courage. The
crown is before you, and ere long Jesus will put it on your head. I
hope all your houshold, as well as yourself, have this in full view. It
glitters, though at this distance. O how bright and radiant! Purchased
at how dear a rate! It is worth striving for. The Lord help you all to
strive so as to obtain. So wishes and prays, dear Mrs. S――,

Your assured friend and servant, for Christ’s sake,

G. W.

LETTER MXLIV.
To Mr. H――.

On board the Success, May 25, 1754.

My dear Mr. H――,

J UST now, through the tender mercies of a never-failing God, we


saw the American shore, and are within a few miles of our desired
port. The wind being contrary, we cannot enter it; I will therefore
employ a few minutes in answering your last kind letter. It was full of
christian love, and bespoke a heart deeply engaged for the success of
the gospel in Gloucestershire. I hope it runs and is glorified, and trust
ere now you find that the blessed Redeemer stands in no need of
such a wretch as I am. Fear not, our Lord will never want instruments
to carry on his work.—A heavenly fire is lighted in England, which men
and devils shall never be able to extinguish. I pray for its spreading
night and day; receive this as a token that none of you are forgotten by
me before the Lord. I believe we have fared the better for your
prayers. Our passage hath been pleasant, and assure yourselves, I
shall make all possible dispatch in order to return unto you. O that it
may be in the fulness of the blessing of the gospel of Christ. Pray
remember me to Mr. R―― C――, to your wife, and all those dear
souls, amongst whom, when last in Gloucestershire, God gave us a
heaven upon earth. O for a heaven in heaven! Blessed be God, that
port is in view. From thence we shall never put to sea any more.
Adieu. I cannot enlarge. Continue to pray for me, as a poor travelling
pilgrim, but, for Christ’s sake,

Yours most affectionately,

G. W.

LETTER MXLV.
To Mr. S――.

Beaufort, Port-Royal Island, South-Carolina,


May 26, 1754.

My dear Friend,

T HROUGH the divine goodness, we are just now sailing into our
harbour, after having been six weeks from Lisbon.—
Providentially a ship goes out to-morrow for Cowes; I cannot omit the
opportunity of sending you a few friendly lines. They come from a
friend, and leave him leaning on Him who hath promised never to
forsake those that put their trust in him. Our passage hath been very
easy, only our entrance into the harbour (like our last struggle before
we enter heaven) hath been somewhat troublesome. May the Lord of
all Lords give you, and yours, and all my never to be forgotten
Yorkshire friends, an abundant entrance there! I must not think of you
too much; parting seasons would come too fresh in my mind.—O
blessed season, when we shall part no more! Adieu, adieu. I hope to
write soon again. My orphan-charge are all quite well, and I hope in a
few days to see them safe at Georgia. I know whose company would
be acceptable to all there; but,—Father thy will be done! I can no
more. Accept this as a token of love unfeigned, from, my dear friend,

Yours for ever and ever, in our common Lord,

G. W.
LETTER MXLVI.
Charles-Town, July 10, 1754.

Dear Mrs. C――,

S INCE I left Bethesda, I have been out two nights by land, and one
by water, and though wearied, am preserved in as good health
as can in any wise be expected. To-morrow or Monday, I expect to
embark again for New-York. The prospect of being ere long at the new
Jerusalem, makes all things easy. I thank you for your kind letter, and
for regarding my tears. They speak better than words. Jesus knows
they were shed for him, and for the welfare of that institution which has
lain so many years upon my poor heart. Have a little patience, and you
will find more and more, that your coming over the water was of God. I
wish it was in my power to make every thing more than agreeable; our
common Lord I trust will do it himself. This is my heart’s desire, and
shall be my constant prayer night and day. You will see what I have
sent by this opportunity. Whatever of the linen or woollen stuff you
would have made up for the children, may be sent by those who bring
this; and what you want done in this way, only let Mrs. B―― have a
line, and orders will be readily executed. Thus God raises up friends.
The Lord be with you all. Help me to praise him, and continue to pray
for, dear Mrs. C――,

Your unworthy friend, and ready servant, for Christ’s sake,

G. W.

LETTER MXLVII.
To Mr. H――.
Charles-Town, July 12, 1754.

Very dear Sir,

T HOUGH I hear that Captain Thompson does not sail, these three
weeks, yet as I am bound for the northward, I cannot help leaving
a few grateful lines behind me. May they find you leaning on the ever-
loving, ever-lovely Jesus, and determined through his strength
steadily to pursue that one thing needful, which shall never be taken
from you! My prayers are continually ascending in your behalf;—they
are your due; I owe you, and shall owe you much love as long as I
live. By this I send you most grateful acknowledgments for all favours,
—they are many, but all noted in my Master’s book. How are my
obligations to love and serve him increased! He gave us a pleasant
passage, and I trust hath blessed my ministry to some souls since my
arrival, and also hath given me to leave my orphan-charge in
comfortable circumstances; the family now consists of above an
hundred. He that fed the multitude in the wilderness, can and will feed
the orphans in Georgia. Your letters I delivered, and I suppose you will
receive proper answers.—But I find Mr. H―― doth not trade at
Lisbon, and Mr. H――m is about to leave off business and retire.
Happy they who can do this, and at the same time that they retire from
the world, retire into God. His presence is all in all. That you may be
blessed with a plentiful portion of it here, and be admitted to an
infinitely greater participation of it hereafter, is the earnest prayer of,
very dear Sir,

Your most obliged friend, and ready servant, for Christ’s


sake,

G. W.

LETTER MXLVIII.
To Mr. C―― W――.
On board the Deborah, July 20, 1754.

My dear Friend,

I DO not forget my promise, though hurrying from place to place, and


settling my orphan-charge, hath almost put it out of my power to
perform it: however, I am now once more on the great deep in my way
to New-York; accept a few lines as a token that you are not forgotten
by me. I wrote to you from Lisbon. From thence we had a pleasant
passage to Carolina, and since that I found and left my orphan family
comfortably settled at Georgia. The colony, as well as Bethesda, is
now in a thriving situation. Black and white persons I have now a
hundred and six to provide for. The God whom I desire to serve, will
enable me to do it for his great name’s sake. At Charles-Town, and in
other parts of Carolina, my poor labours have met with the usual
acceptance, and I have reason to hope a clergyman hath been
brought under very serious impressions. Not unto me, O Lord, not
unto me, but unto thy free grace be all the glory! What will befal me at
the northward, I know not; this I know, that Jesus Christ will suffer
nothing to pluck me out of his hands. My health is wonderfully
preserved.—My wonted vomitings have left me, and though I ride
whole nights, and have been frequently exposed to great thunders,
violent lightnings, and heavy rains, yet I am rather better than usual,
and as far as I can judge, am not yet to die. O that I may at length
learn to begin to live. I am ashamed of my sloth and lukewarmness,
and long to be on the stretch for God. I hope this will find you thus
employed. My cordial love awaits your whole self, your brother, Mr.
B――, and in short all the followers of the blessed Lamb of God.
Though unworthy of their notice, I earnestly intreat a continued interest
in their prayers, as being, my very dear Sir,

Their and your affectionate friend, and ready servant in our


common Lord,

G. W.
LETTER MXLIX.
To Mr. D――.

On board the Deborah, July 20, 1754.

My very dear Mr. D――,

T HIS leaves me on my way towards New-York. Accept this as a


token, that change of climate doth not cause a change of
affection. No, you and my other dear Edinburgh friends are still upon
my heart, and I trust will remain fixed there, till we meet to join the
singing choir that is about the throne. I hope you have an earnest and
anticipation of this, every Monday evening. I hope you enjoy a feeling
possession of your God, every day and every hour. This will make the
most barren wilderness to smile, and support you under the most
distressing circumstances. It is this that supports me by land and by
water. Without it, what could such a poor, weak, faint-hearted pilgrim
do? Verily I should faint.—But as yet I cannot die. In spite of thunder,
lightning, rain, and heat, God is pleased to hold my soul in life, and to
let me see his glorious work prosper in my unworthy hands. Georgia
and Bethesda I found in a thriving way. My family consists of a
hundred and six, and will prove I trust of more extensive use every
day. About six weeks I staid at Carolina and Georgia. One is likely to
be settled as minister in Charles-Town. There my poor labours have
met with usual acceptance, and I live in hopes of some gracious gales
to the northward. Perhaps about Christmas, or early in the spring, I
may see my native country again.—O may I return grown in grace,
and in the knowledge of my Lord and Saviour Jesus Christ! But I
am a dwarf. Pray, pray for me. Accept unfeigned thanks for all favours,
remember me in the kindest manner to all inquiring friends, and
believe me to be, my very dear Sir,

Yours, &c. in our glorious Head,

G. W.

You might also like