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

The Python Workbook: A Brief Introduction with Exercises and Solutions 2nd Edition Ben Stephenson download

The document provides information about 'The Python Workbook: A Brief Introduction with Exercises and Solutions 2nd Edition' by Ben Stephenson, which emphasizes hands-on programming experience through exercises. It contains 186 exercises covering various topics in Python programming, with solutions and annotations to aid learning. The book can serve as a standalone textbook or a supplement for other programming resources.

Uploaded by

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

The Python Workbook: A Brief Introduction with Exercises and Solutions 2nd Edition Ben Stephenson download

The document provides information about 'The Python Workbook: A Brief Introduction with Exercises and Solutions 2nd Edition' by Ben Stephenson, which emphasizes hands-on programming experience through exercises. It contains 186 exercises covering various topics in Python programming, with solutions and annotations to aid learning. The book can serve as a standalone textbook or a supplement for other programming resources.

Uploaded by

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

The Python Workbook: A Brief Introduction with

Exercises and Solutions 2nd Edition Ben


Stephenson download

https://textbookfull.com/product/the-python-workbook-a-brief-
introduction-with-exercises-and-solutions-2nd-edition-ben-
stephenson/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

The Python Workbook A Brief Introduction with Exercises


and Solutions 2014th Edition Stephenson Ben

https://textbookfull.com/product/the-python-workbook-a-brief-
introduction-with-exercises-and-solutions-2014th-edition-
stephenson-ben/

Introduction to Statistics and Data Analysis With


Exercises Solutions and Applications in R 1st Edition
Christian Heumann

https://textbookfull.com/product/introduction-to-statistics-and-
data-analysis-with-exercises-solutions-and-applications-in-r-1st-
edition-christian-heumann/

Naturalness String Landscape and Multiverse A Modern


Introduction with Exercises Arthur Hebecker

https://textbookfull.com/product/naturalness-string-landscape-
and-multiverse-a-modern-introduction-with-exercises-arthur-
hebecker/

Data Mining with SPSS Modeler Theory Exercises and


Solutions 1st Edition Tilo Wendler

https://textbookfull.com/product/data-mining-with-spss-modeler-
theory-exercises-and-solutions-1st-edition-tilo-wendler/
AWS Certified Solutions Architect Study Guide 2nd
Edition Ben Piper

https://textbookfull.com/product/aws-certified-solutions-
architect-study-guide-2nd-edition-ben-piper/

A Brief Introduction to Dispersion Relations With


Modern Applications José Antonio Oller

https://textbookfull.com/product/a-brief-introduction-to-
dispersion-relations-with-modern-applications-jose-antonio-oller/

Sociology: A Brief Introduction Richard T. Schaefer

https://textbookfull.com/product/sociology-a-brief-introduction-
richard-t-schaefer/

Programming For Computations - Python: A Gentle


Introduction To Numerical Simulations With Python 3.6
Svein Linge

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

A Brief Introduction to the New Testament Bart D.


Ehrman

https://textbookfull.com/product/a-brief-introduction-to-the-new-
testament-bart-d-ehrman/
Texts in Computer Science

Ben Stephenson

The Python
Workbook
A Brief Introduction with Exercises
and Solutions
Second Edition
Texts in Computer Science

Series Editors
David Gries, Department of Computer Science, Cornell University, Ithaca, NY,
USA
Orit Hazzan, Faculty of Education in Technology and Science, Technion—Israel
Institute of Technology, Haifa, Israel
More information about this series at http://www.springer.com/series/3191
Ben Stephenson

The Python Workbook


A Brief Introduction with Exercises
and Solutions
Second Edition

123
Ben Stephenson
Department of Computer Science
University of Calgary
Calgary, AB, Canada

ISSN 1868-0941 ISSN 1868-095X (electronic)


Texts in Computer Science
ISBN 978-3-030-18872-6 ISBN 978-3-030-18873-3 (eBook)
https://doi.org/10.1007/978-3-030-18873-3
1st edition: © Springer International Publishing Switzerland 2014
2nd edition: © Springer Nature Switzerland AG 2019
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar
methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this
publication does not imply, even in the absence of a specific statement, that such names are exempt from
the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this
book are believed to be true and accurate at the date of publication. Neither the publisher nor the
authors or the editors give a warranty, expressed or implied, with respect to the material contained
herein or for any errors or omissions that may have been made. The publisher remains neutral with regard
to jurisdictional claims in published maps and institutional affiliations.

This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
To my wife, Flora, for 16 fantastic years of
marriage, and many more to come. To my
sons, Jonathan and Andrew, who were both
in a hurry to enter the world. I love you all.
Preface

I believe that computer programming is a skill that is best learned through hands-on
experience. While it is valuable for you to read about programming in textbooks
and watch teachers create programs at the front of classrooms, it is even more
important for you to spend time-solving problems that allow you to put program-
ming concepts into practice. With this in mind, the majority of the pages in this
book are dedicated to exercises and their solutions while only a few pages are used
to briefly introduce the concepts needed to complete them.
This book contains 186 exercises that span a variety of academic disciplines and
everyday situations. They can be solved using only the material covered in most
introductory Python programming courses. Each exercise that you complete will
strengthen your understanding of the Python programming language and enhance
your ability to tackle subsequent programming challenges. I also hope that the
connections that these exercises make to other academic disciplines and everyday
life will maintain your interest as you complete them.
Solutions to approximately half of the exercises are provided in the second half
of this book. Most of the solutions include brief annotations that explain the
technique used to solve the problem or highlight a specific point of Python syntax.
You will find these annotations in shaded boxes, making it easy to distinguish them
from the solution itself.
I hope that you will take the time to compare each of your solutions with mine,
even when you arrive at your solution without encountering any problems. Per-
forming this comparison may reveal a flaw in your program, or help you become
more familiar with a technique that you could have used to solve the problem more
easily. In some cases, it could also reveal that you have discovered a faster or easier
way to solve the problem than I have. If you become stuck on an exercise, a quick
peek at my solution may help you work through your problem and continue to
make progress without requiring assistance from someone else. Finally, the solu-
tions that I have provided demonstrate good programming style, including appro-
priate comments, meaningful variable names, and minimal use of magic numbers.
I encourage you to use good programming style when creating your solutions so
that they compute the correct result while also being clear, easy to understand, and
amenable to being updated in the future.

vii
viii Preface

Exercises that include a solution are clearly marked with (Solved) next to the
exercise name. The length of the sample solution is also stated for every exercise in
this book. While you shouldn’t expect your solution length to match the sample
solution length exactly, I hope that providing this information will prevent you from
going too far astray before seeking assistance.
This book can be used in a variety of ways. Its concise introductions to major
Python programming concepts, which are new in this edition, allow it to be used as
the lone textbook for an introductory programming course. It can also be used to
supplement another textbook that has a limited selection of exercises. A motivated
individual could teach themselves to program in Python using only this book,
though there are, perhaps, easier ways to learn the language because the concise
introductions to each topic cover only their most important aspects, without
examining every special case or unusual circumstance. No matter what other
resources you use with this book, if any, reading the chapters, completing the
exercises, and studying the provided solutions will enhance your programming
ability.

Acknowledgements

I would like to thank Dr. Tom Jenkyns for reviewing this book as it was being
created. His helpful comments and suggestions resulted in numerous refinements
and corrections that improved the quality of this work.

Calgary, Canada Ben Stephenson


March 2019
Contents

Part I Exercises
1 Introduction to Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 Storing and Manipulating Values . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Calling Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4 Formatting Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Working with Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2 Decision Making . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.1 If Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2 If-Else Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3 If-Elif-Else Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.4 If-Elif Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.5 Nested If Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.6 Boolean Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3 Repetition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.1 While Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.2 For Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.3 Nested Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.1 Functions with Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.2 Variables in Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.3 Return Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.4 Importing Functions into Other Programs . . . . . . . . . . . . . . . . . . 65
4.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.1 Accessing Individual Elements . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.2 Loops and Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

ix
x Contents

5.3 Additional List Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78


5.4 Lists as Return Values and Arguments . . . . . . . . . . . . . . . . . . . . 82
5.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
6 Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
6.1 Accessing, Modifying and Adding Values . . . . . . . . . . . . . . . . . 98
6.2 Removing a Key-Value Pair . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.3 Additional Dictionary Operations . . . . . . . . . . . . . . . . . . . . . . . . 99
6.4 Loops and Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.5 Dictionaries as Arguments and Return Values . . . . . . . . . . . . . . 101
6.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
7 Files and Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
7.1 Opening a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
7.2 Reading Input from a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
7.3 End of Line Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
7.4 Writing Output to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
7.5 Command Line Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
7.6 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
7.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
8 Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
8.1 Summing Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
8.2 Fibonacci Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
8.3 Counting Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
8.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

Part II Solutions
9 Solutions to the Introduction to Programming Exercises . . . . . . . . 143
10 Solutions to the Decision Making Exercises . . . . . . . . . . . . . . . . . . 151
11 Solutions to the Repetition Exercises . . . . . . . . . . . . . . . . . . . . . . . . 161
12 Solutions to the Function Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 169
13 Solutions to the List Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
14 Solutions to the Dictionary Exercises . . . . . . . . . . . . . . . . . . . . . . . 193
15 Solutions to the File and Exception Exercises . . . . . . . . . . . . . . . . . 199
16 Solutions to the Recursion Exercises . . . . . . . . . . . . . . . . . . . . . . . . 209
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Part I
Exercises
Introduction to Programming
1

Computers help us perform many different tasks. They allow us to read the news,
watch videos, play games, write books, purchase goods and services, perform com-
plex mathematical analyses, communicate with friends and family, and so much
more. All of these tasks require the user to provide input, such as clicking on a video
to watch, or typing the sentences that should be included in a book. In response, the
computer generates output, such as printing a book, playing sounds, or displaying
text and images on the screen.
Consider the examples in the previous paragraph. How did the computer know
what input to request? How did it know what actions to take in response to the input?
How did it know what output to generate, and in what form it should be presented?
The answer to all of these questions is “a person gave the computer instructions and
the computer carried them out”.
An algorithm is a finite sequence of effective steps that solve a problem. A step is
effective if it is unambiguous and possible to perform. The number of steps must be
finite (rather than infinite) so that all of the steps can be completed. Recipes, assembly
instructions for furniture or toys, and the steps needed to open a combination lock
are examples of algorithms that we encounter in everyday life.
The form in which an algorithm is presented is flexible and can be tailored to
the problem that the algorithm solves. Words, numbers, lines, arrows, pictures and
other symbols can all be used to convey the steps that must be performed. While the
forms that algorithms take vary, all algorithms describe steps that can be followed to
complete a task successfully.
A computer program is a sequence of instructions that control the behaviour of
a computer. The instructions tell the computer when to perform tasks like reading
input and displaying results, and how to transform and manipulate values to achieve a
desired outcome. An algorithm must be translated into a computer program before a
computer can be used to solve a problem. The translation process is called program-
ming and the person who performs the translation is referred to as a programmer.

© Springer Nature Switzerland AG 2019 3


B. Stephenson, The Python Workbook, Texts in Computer Science,
https://doi.org/10.1007/978-3-030-18873-3_1
4 1 Introduction to Programming

Computer programs are written in computer programming languages. Program-


ming languages have precise syntax rules that must be followed carefully. Failing to
do so will cause the computer to report an error instead of executing the programmer’s
instructions. A wide variety of different languages have been created, each of which
has its own strengths and weaknesses. Popular programming languages currently
include Java, C++, JavaScript, PHP, C# and Python, among others. While there are
significant differences between these languages all of them allow a programmer to
control the computer’s behaviour.
This book uses the Python programming language because it is relatively easy for
new programmers to learn, and it can be used to solve a wide variety of problems.
Python statements that read keyboard input from the user, perform calculations, and
generate text output are described in the sections that follow. Later chapters describe
additional programming language constructs that can be used to solve larger and
more complex problems.

1.1 Storing and Manipulating Values

A variable is a named location in a computer’s memory that holds a value. In Python,


variable names must begin with a letter or an underscore, followed by any combi-
nation of letters, underscores and numbers.1 Variables are created using assignment
statements. The name of the variable that we want to create appears to the left of the
assignment operator, which is denoted by =, and the value that will be stored in the
variable appears to the right of the assignment operator. For example, the following
statement creates a variable named x and stores 5 in it:
x = 5

The right side of an assignment statement can be an arbitrarily complex calcu-


lation that includes parentheses, mathematical operators, numbers, and variables
that were created by earlier assignment statements (among other things). Familiar
mathematical operators that Python provides include addition (+), subtraction (−),
multiplication (*), division (/), and exponentiation (**). Operators are also provided
for floor division (//) and modulo (%). The floor division operator computes the floor
of the quotient that results when one number is divided by another while the modulo
operator computes the remainder when one number is divided by another.
The following assignment statement computes the value of one plus x squared
and stores it in a new variable named y.
y = 1 + x ** 2

1 Variable
names are case sensitive. As a result, count, Count and COUNT are distinct variable
names, despite their similarity.
1.1 Storing and Manipulating Values 5

Python respects the usual order of operations rules for mathematical operators. Since
x is 5 (from the previous assignment statement) and exponentiation has higher prece-
dence than addition, the expression to the right of the assignment operator evaluates
to 26. Then this value is stored in y.
The same variable can appear on both sides of an assignment operator. For
example:
y = y - 6

While your initial reaction might be that such a statement is unreasonable, it is, in
fact, a valid Python statement that is evaluated just like the assignment statements
we examined previously. Specifically, the expression to the right of the assignment
operator is evaluated and then the result is stored into the variable to the left of
the assignment operator. In this particular case y is 26 when the statement starts
executing, so 6 is subtracted from y resulting in 20. Then 20 is stored into y, replacing
the 26 that was stored there previously. Subsequent uses of y will evaluate to the
newly stored value of 20 (until it is changed with another assignment statement).

1.2 Calling Functions

There are some tasks that many programs have to perform such as reading input
values from the keyboard, sorting a list, and computing the square root of a number.
Python provides functions that perform these common tasks, as well as many others.
The programs that we create will call these functions so that we don’t have to solve
these problems ourselves.
A function is called by using its name, followed by parentheses. Many functions
require values when they are called, such as a list of names to sort or the number for
which the square root will be computed. These values, called arguments, are placed
inside the parentheses when the function is called. When a function call has multiple
arguments they are separated by commas.
Many functions compute a result. This result can be stored in a variable using an
assignment statement. The name of the variable appears to the left of the assignment
operator and the function call appears to the right of the assignment operator. For
example, the following assignment statement calls the round function, which rounds
a number to the closest integer.
r = round(q)

The variable q (which must have been assigned a value previously) is passed as an
argument to the round function. When the round function executes it identifies
the integer that is closest to q and returns it. Then the returned integer is stored in r.
6 1 Introduction to Programming

1.2.1 Reading Input

Python programs can read input from the keyboard by calling the input function.
This function causes the program to stop and wait for the user to type something.
When the user presses the enter key the characters typed by the user are returned
by the input function. Then the program continues executing. Input values are
normally stored in a variable using an assignment statement so that they can be used
later in the program. For example, the following statement reads a value typed by
the user and stores it in a variable named a.
a = input()

The input function always returns a string, which is computer science terminol-
ogy for a sequence of characters. If the value being read is a person’s name, the title
of a book, or the name of a street, then storing the value as a string is appropriate.
But if the value is numeric, such as an age, a temperature, or the cost of a meal at a
restaurant, then the string entered by the user is normally converted to a number. The
programmer must decide whether the result of the conversion should be an integer
or a floating-point number (a number that can include digits to the right of the deci-
mal point). Conversion to an integer is performed by calling the int function while
conversion to a floating-point number is performed by calling the float function.
It is common to call the int and float functions in the same assignment state-
ment that reads an input value from the user. For example, the following statements
read a customer’s name, the quantity of an item that they would like to purchase, and
the item’s price. Each of these values is stored in its own variable with an assignment
statement. The name is stored as a string, the quantity is stored as an integer, and the
price is stored as a floating-point number.
name = input("Enter your name: ")
quantity = int(input("How many items? "))
price = float(input("Cost per item? "))

Notice that an argument was provided to the input function each time it was
called. This argument, which is optional, is a prompt that tells the user what to enter.
The prompt must be string. It is enclosed in double quotes so that Python knows to
treat the characters as a string instead of interpreting them as the names of functions
or variables.
Mathematical calculations can be performed on both integers and floating-point
numbers. For example, another variable can be created that holds the total cost of
the items with the following assignment statement:
total = quantity * price

This statement will only execute successfully if quantity and price have been
converted to numbers using the int and float functions described previously.
Attempting to multiply these values without converting them to numbers will cause
your Python program to crash.
1.2 Calling Functions 7

1.2.2 Displaying Output

Text output is generated using the print function. It can be called with one argu-
ment, which is the value that will be displayed. For example, the following statements
print the number 1, the string Hello!, and whatever is currently stored in the vari-
able x. The value in x could be an integer, a floating-point number, a string, or a
value of some other type that we have not yet discussed. Each item is displayed on
its own line.
print(1)
print("Hello!")
print(x)

Multiple values can be printed with one function call by providing several argu-
ments to the print function. The additional arguments are separated by commas.
For example:
print("When x is", x, "the value of y is", y)

All of these values are printed on the same line. The arguments that are enclosed in
double quotes are strings that are displayed exactly as typed. The other arguments
are variables. When a variable is printed, Python displays the value that is currently
stored in it. A space is automatically included between each item when multiple
items are printed.
The arguments to a function call can be values and variables, as shown previously.
They can also be arbitrarily complex expressions involving parentheses, mathemat-
ical operators and other function calls. Consider the following statement:
print("The product of", x, "and", y, "is", x * y)

When it executes, the product, x * y, is computed and then displayed along with
all of the other arguments to the print function.

1.2.3 Importing Additional Functions

Some functions, like input and print are used in many programs while others are
not used as broadly. The most commonly used functions are available in all programs,
while other less commonly used functions are stored in modules that the programmer
can import when they are needed. For example, additional mathematical functions
are located in the math module. It can be imported by including the following
statement at the beginning of your program:
import math

Functions in the math module include sqrt, ceil and sin, among many
others. A function imported from a module is called by using the module name,
8 1 Introduction to Programming

followed by a period, followed by the name of the function and its arguments. For
example, the following statement computes the square root of y (which must have
been initialized previously) and stores the result in z by calling the math module’s
sqrt function.
z = math.sqrt(y)

Other commonly used Python modules include random, time and sys, among
others. More information about all of these modules can be found online.

1.3 Comments

Comments give programmers the opportunity to explain what, how or why they
are doing something in their program. This information can be very helpful when
returning to a project after being away from it for a period of time, or when working
on a program that was initially created by someone else. The computer ignores all
of the comments in the program. They are only included to benefit people.
In Python, the beginning of a comment is denoted by the # character. The comment
continues from the # character to the end of the line. A comment can occupy an entire
line, or just part of it, with the comment appearing to the right of a Python statement.
Python files commonly begin with a comment that briefly describes the program’s
purpose. This allows anyone looking at the file to quickly determine what the program
does without carefully examining its code. Commenting your code also makes it
much easier to identify which lines perform each of the tasks needed to compute the
program’s results. You are strongly encouraged to write thorough comments when
completing all of the exercises in this book.

1.4 Formatting Values

Sometimes the result of a mathematical calculation will be a floating-point number


that has many digits to the right of the decimal point. While one might want to
display all of the digits in some programs, there are other circumstances where the
value must be rounded to a particular number of decimal places. Another unrelated
program might output a large number of integers that need to be lined up in columns.
Python’s formatting constructs allow us to accomplish these, and many other, tasks.
A programmer tells Python how to format a value using a format specifier. The
specifier is a sequence of characters that describe a variety of formatting details.
It uses one character to indicate what type of formatting should be performed. For
example, an f indicates that a value should be formatted as a floating-point number
while a d or an i indicates that a value should be formatted as a decimal (base-10)
integer and an s indicates that a value should be formatted as a string. Characters
1.4 Formatting Values 9

can precede the f, d, i or s to control additional formatting details. We will only


consider the problems of formatting a floating-point number so that it includes a
specific number of digits to the right of the decimal point and formatting values so
that they occupy some minimum number of characters (which allows values to be
printed in columns that line up nicely). Many additional formatting tasks can be
performed using format specifiers, but these tasks are outside the scope of this book.
A floating-point number can be formatted to include a specific number of decimal
places by including a decimal point and the desired number of digits immediately
ahead of the f in the format specifier. For example, .2f is used to indicate that a
value should be formatted as a floating-point number with two digits to the right of
the decimal point while .7f indicates that 7 digits should appear to the right of the
decimal point. Rounding is performed when the number of digits to the right of the
decimal point is reduced. Zeros are added if the number of digits is increased. The
number of digits to the right of the decimal point cannot be specified when formatting
integers and strings.
Integers, floating-point numbers and strings can all be formatted so that they
occupy at least some minimum width. Specifying a minimum width is useful when
generating output that includes columns of values that need to be lined up. The
minimum number of characters to use is placed before the d, i, f or s, and before
the decimal point and number of digits to the right of the decimal point (if present).
For example, 8d indicates that a value should be formatted as a decimal integer
occupying a minimum of 8 characters while 6.2f indicates that a value should be
formatted as a floating-point number using a minimum of 6 characters, including
the decimal point and the two digits to its right. Leading spaces are added to the
formatted value, when needed, to reach the minimum number of characters.
Finally, once the correct formatting characters have been identified, a percent sign
(%) is prepended to them. A format specifier normally appears in a string. It can be
the only characters in the string, or it can be part of a longer message. Examples
of complete format specifier strings include "%8d", "The amount owing is
%.2f" and "Hello %s! Welcome aboard!".
Once the format specifier has been created the formatting operator, denoted by %,
is used to format a value.2 The string containing the format specifier appears to the
left of the formatting operator. The value being formatted appears to its right. When
the formatting operator is evaluated, the value on the right is inserted into the string
on the left (at the location of the format specifier using the indicated formatting)
to compute the operator’s result. Any characters in the string that are not part of a
format specifier are retained without modification. Multiple values can be formatted
simultaneously by including multiple format specifiers in the string to the left of the
formatting operator, and by comma separating all of the values to be formatted inside
parentheses to the right of the formatting operator.

2 Python provides several different mechanisms for formatting strings including the formatting
operator, the format function and format method, template strings and, most recently, f-strings.
We will use the formatting operator for all of the examples and exercises in this book but the other
techniques can also be used to achieve the same results.
10 1 Introduction to Programming

String formatting is often performed as part of a print statement. The first


print statement in the following code segment displays the value of the variable x,
with exactly two digits to the right of the decimal point. The second print statement
formats two values before displaying them as part of a larger output message.
print("%.2f" % x)
print("%s ate %d cookies!" % (name, numCookies))

Several additional formatting examples are shown in the following table. The
variables x, y and z have previously been assigned 12, -2.75 and "Andrew"
respectively.

Code Segment: "%d" % x


Result: "12"
Explanation: The value stored in x is formatted as a decimal (base 10) integer.
Code Segment: "%f" % y
Result: "-2.75"
Explanation: The value stored in y is formatted as a floating-point number.
Code Segment: "%d and %f" % (x, y)
Result: "12 and -2.75"
Explanation: The value stored in x is formatted as a decimal (base 10) integer and the value
stored in y is formatted as a floating-point number. The other characters in
the string are retained without modification.
Code Segment: "%.4f" % x
Result: "12.0000"
Explanation: The value stored in x is formatted as a floating-point number with 4 digits
to the right of the decimal point.
Code Segment: "%.1f" % y
Result: "-2.8"
Explanation: The value stored in y is formatted as a floating-point number with 1 digit to
the right of the decimal point. The value was rounded when it was formatted
because the number of digits to the right of the decimal point was reduced.
Code Segment: "%10s" % z
Result: " Andrew"
Explanation: The value stored in z is formatted as a string so that it occupies at least 10
spaces. Because z is only 6 characters long, 4 leading spaces are included
in the result.
Code Segment: "%4s" % z
Result: "Andrew"
Explanation: The value stored in z is formatted as a string so that it occupies at least 4
spaces. Because z is longer than the indicated minimum length, the resulting
string is equal to z.
Code Segment: "%8i%8i" % (x, y)
Result: " 12 -2"
Explanation: Both x and y are formatted as decimal (base 10) integers occupying a
minimum of 8 spaces. Leading spaces are added as necessary. The digits to
the right of decimal point are truncated (not rounded) when y (a floating-
point number) is formatted as an integer.
1.5 Working with Strings 11

1.5 Working with Strings

Like numbers, strings can be manipulated with operators and passed to functions.
Operations that are commonly performed on strings include concatenating two
strings, computing the length of a string, and extracting individual characters from
a string. These common operations are described in the remainder of this section.
Information about other string operations can be found online.
Strings can be concatenated using the + operator. The string to the right of the
operator is appended to the string to the left of the operator to form the new string.
For example, the following program reads two strings from the user which are a
person’s first and last names. It then uses string concatenation to construct a new
string which is the person’s last name, followed by a comma and a space, followed
by the person’s first name. Then the result of the concatenation is displayed.

# Read the names from the user


first = input("Enter the first name: ")
last = input("Enter the last name: ")

# Concatenate the strings


both = last + ", " + first

# Display the result


print(both)

The number of characters in a string is referred to as a string’s length. This value,


which is always a non-negative integer, is computed by calling the len function. A
string is passed to the function as its only argument and the length of that string is
returned as its only result. The following example demonstrates the len function by
computing the length of a person’s name.

# Read the name from the user


first = input("Enter your first name: ")

# Compute its length


num_chars = len(first)

# Display the result


print("Your first name contains", num_chars, "characters")

Sometimes it is necessary to access individual characters within a string. For


example, one might want to extract the first character from each of three strings
containing a first name, middle name and last name, in order to display a person’s
initials.
Each character in a string has a unique integer index. The first character in the
string has index 0 while the last character in the string has an index which is equal
to the length of the string, minus one. A single character in a string is accessed by
placing its index inside square brackets after the name of the variable containing the
string. The following program demonstrates this by displaying a person’s initials.
12 1 Introduction to Programming

# Read the user’s name


first = input("Enter your first name: ")
middle = input("Enter your middle name: ")
last = input("Enter your last name: ")

# Extract the first character from each string and concatenate them
initials = first[0] + middle[0] + last[0]

# Display the initials


print("Your initials are", initials)

Several consecutive characters in a string can be accessed by including two indices,


separated by a colon, inside the square brackets. This is referred to as slicing a string.
String slicing can be used to access multiple characters within a string in an efficient
manner.

1.6 Exercises

The exercises in this chapter will allow you to put the concepts discussed previously
into practice. While the tasks that they ask you to complete are generally small,
solving these exercises is an important step toward the creation of larger programs
that solve more interesting problems.

Exercise 1: Mailing Address


(Solved, 9 Lines)
Create a program that displays your name and complete mailing address. The address
should be printed in the format that is normally used in the area where you live. Your
program does not need to read any input from the user.

Exercise 2: Hello
(9 Lines)
Write a program that asks the user to enter his or her name. The program should
respond with a message that says hello to the user, using his or her name.

Exercise 3: Area of a Room


(Solved, 13 Lines)
Write a program that asks the user to enter the width and length of a room. Once
these values have been read, your program should compute and display the area of
the room. The length and the width will be entered as floating-point numbers. Include
units in your prompt and output message; either feet or meters, depending on which
unit you are more comfortable working with.
1.6 Exercises 13

Exercise 4: Area of a Field


(Solved, 15 Lines)
Create a program that reads the length and width of a farmer’s field from the user in
feet. Display the area of the field in acres.

Hint: There are 43,560 square feet in an acre.

Exercise 5: Bottle Deposits


(Solved, 15 Lines)
In many jurisdictions a small deposit is added to drink containers to encourage people
to recycle them. In one particular jurisdiction, drink containers holding one liter or
less have a $0.10 deposit, and drink containers holding more than one liter have a
$0.25 deposit.
Write a program that reads the number of containers of each size from the user.
Your program should continue by computing and displaying the refund that will be
received for returning those containers. Format the output so that it includes a dollar
sign and two digits to the right of the decimal point.

Exercise 6: Tax and Tip


(Solved, 17 Lines)
The program that you create for this exercise will begin by reading the cost of a meal
ordered at a restaurant from the user. Then your program will compute the tax and
tip for the meal. Use your local tax rate when computing the amount of tax owing.
Compute the tip as 18 percent of the meal amount (without the tax). The output from
your program should include the tax amount, the tip amount, and the grand total for
the meal including both the tax and the tip. Format the output so that all of the values
are displayed using two decimal places.

Exercise 7: Sum of the First n Positive Integers


(Solved, 11 Lines)
Write a program that reads a positive integer, n, from the user and then displays the
sum of all of the integers from 1 to n. The sum of the first n positive integers can be
computed using the formula:

(n)(n + 1)
sum =
2
14 1 Introduction to Programming

Exercise 8: Widgets and Gizmos


(15 Lines)
An online retailer sells two products: widgets and gizmos. Each widget weighs 75
grams. Each gizmo weighs 112 grams. Write a program that reads the number of
widgets and the number of gizmos from the user. Then your program should compute
and display the total weight of the parts.

Exercise 9: Compound Interest


(19 Lines)
Pretend that you have just opened a new savings account that earns 4 percent interest
per year. The interest that you earn is paid at the end of the year, and is added to the
balance of the savings account. Write a program that begins by reading the amount of
money deposited into the account from the user. Then your program should compute
and display the amount in the savings account after 1, 2, and 3 years. Display each
amount so that it is rounded to 2 decimal places.

Exercise 10: Arithmetic


(Solved, 22 Lines)
Create a program that reads two integers, a and b, from the user. Your program should
compute and display:

• The sum of a and b


• The difference when b is subtracted from a
• The product of a and b
• The quotient when a is divided by b
• The remainder when a is divided by b
• The result of log10 a
• The result of a b

Hint: You will probably find the log10 function in the math module helpful
for computing the second last item in the list.

Exercise 11: Fuel Efficiency


(13 Lines)
In the United States, fuel efficiency for vehicles is normally expressed in miles-per-
gallon (MPG). In Canada, fuel efficiency is normally expressed in liters-per-hundred
kilometers (L/100 km). Use your research skills to determine how to convert from
MPG to L/100 km. Then create a program that reads a value from the user in American
units and displays the equivalent fuel efficiency in Canadian units.
1.6 Exercises 15

Exercise 12: Distance Between Two Points on Earth


(27 Lines)
The surface of the Earth is curved, and the distance between degrees of longitude
varies with latitude. As a result, finding the distance between two points on the surface
of the Earth is more complicated than simply using the Pythagorean theorem.
Let (t1 , g1 ) and (t2 , g2 ) be the latitude and longitude of two points on the Earth’s
surface. The distance between these points, following the surface of the Earth, in
kilometers is:

distance = 6371.01 × arccos(sin(t1 ) × sin(t2 ) + cos(t1 ) × cos(t2 ) × cos(g1 − g2 ))

The value 6371.01 in the previous equation wasn’t selected at random. It is the
average radius of the Earth in kilometers.

Create a program that allows the user to enter the latitude and longitude of two
points on the Earth in degrees. Your program should display the distance between
the points, following the surface of the earth, in kilometers.

Hint: Python’s trigonometric functions operate in radians. As a result, you will


need to convert the user’s input from degrees to radians before computing the
distance with the formula discussed previously. The math module contains a
function named radians which converts from degrees to radians.

Exercise 13: Making Change


(Solved, 35 Lines)
Consider the software that runs on a self-checkout machine. One task that it must be
able to perform is to determine how much change to provide when the shopper pays
for a purchase with cash.
Write a program that begins by reading a number of cents from the user as an
integer. Then your program should compute and display the denominations of the
coins that should be used to give that amount of change to the shopper. The change
should be given using as few coins as possible. Assume that the machine is loaded
with pennies, nickels, dimes, quarters, loonies and toonies.

A one dollar coin was introduced in Canada in 1987. It is referred to as a loonie


because one side of the coin has a loon (a type of bird) on it. The two dollar
coin, referred to as a toonie, was introduced 9 years later. It’s name is derived
from the combination of the number two and the name of the loonie.
16 1 Introduction to Programming

Exercise 14: Height Units


(Solved, 16 Lines)
Many people think about their height in feet and inches, even in some countries that
primarily use the metric system. Write a program that reads a number of feet from
the user, followed by a number of inches. Once these values are read, your program
should compute and display the equivalent number of centimeters.

Hint: One foot is 12 inches. One inch is 2.54 centimeters.

Exercise 15: Distance Units


(20 Lines)
In this exercise, you will create a program that begins by reading a measurement
in feet from the user. Then your program should display the equivalent distance in
inches, yards and miles. Use the Internet to look up the necessary conversion factors
if you don’t have them memorized.

Exercise 16: Area and Volume


(15 Lines)
Write a program that begins by reading a radius, r , from the user. The program will
continue by computing and displaying the area of a circle with radius r and the
volume of a sphere with radius r . Use the pi constant in the math module in your
calculations.

Hint: The area of a circle is computed using the formula area = πr 2 . The
volume of a sphere is computed using the formula volume = 43 πr 3 .

Exercise 17: Heat Capacity


(Solved, 23 Lines)
The amount of energy required to increase the temperature of one gram of a material
by one degree Celsius is the material’s specific heat capacity, C. The total amount
of energy, q, required to raise m grams of a material by ΔT degrees Celsius can be
computed using the formula:
q = mCΔT
Write a program that reads the mass of some water and the temperature change from
the user. Your program should display the total amount of energy that must be added
or removed to achieve the desired temperature change.
1.6 Exercises 17

Hint: The specific heat capacity of water is 4.186 g◦JC . Because water has a
density of 1.0 grams per milliliter, you can use grams and milliliters inter-
changeably in this exercise.

Extend your program so that it also computes the cost of heating the water. Elec-
tricity is normally billed using units of kilowatt hours rather than Joules. In this
exercise, you should assume that electricity costs 8.9 cents per kilowatt hour. Use
your program to compute the cost of boiling the water needed for a cup of coffee.

Hint: You will need to look up the factor for converting between Joules and
kilowatt hours to complete the last part of this exercise.

Exercise 18: Volume of a Cylinder


(15 Lines)
The volume of a cylinder can be computed by multiplying the area of its circular
base by its height. Write a program that reads the radius of the cylinder, along with
its height, from the user and computes its volume. Display the result rounded to one
decimal place.

Exercise 19: Free Fall


(Solved, 15 Lines)
Create a program that determines how quickly an object is travelling when it hits the
ground. The user will enter the height from which the object is dropped in meters (m).
Because the object is dropped its initial speed is 0 m/s. Assume
 that the acceleration
due to gravity is 9.8 m/s2 . You can use the formula vf = vi2 + 2ad to compute the
final speed, vf , when the initial speed, vi , acceleration, a, and distance, d, are known.

Exercise 20: Ideal Gas Law


(19 Lines)
The ideal gas law is a mathematical approximation of the behavior of gasses as
pressure, volume and temperature change. It is usually stated as:

PV = nRT

where P is the pressure in Pascals, V is the volume in liters, n is the amount of


substance in moles, R is the ideal gas constant, equal to 8.314 molJ K , and T is the
temperature in degrees Kelvin.
18 1 Introduction to Programming

Write a program that computes the amount of gas in moles when the user supplies
the pressure, volume and temperature. Test your program by determining the number
of moles of gas in a SCUBA tank. A typical SCUBA tank holds 12 liters of gas at
a pressure of 20,000,000 Pascals (approximately 3,000 PSI). Room temperature is
approximately 20 degrees Celsius or 68 degrees Fahrenheit.

Hint: A temperature is converted from Celsius to Kelvin by adding 273.15


to it. To convert a temperature from Fahrenheit to Kelvin, deduct 32 from it,
multiply it by 59 and then add 273.15 to it.

Exercise 21: Area of a Triangle


(13 Lines)
The area of a triangle can be computed using the following formula, where b is the
length of the base of the triangle, and h is its height:

b×h
area =
2
Write a program that allows the user to enter values for b and h. The program should
then compute and display the area of a triangle with base length b and height h.

Exercise 22: Area of a Triangle (Again)


(16 Lines)
In the previous exercise you created a program that computed the area of a triangle
when the length of its base and its height were known. It is also possible to compute
the area of a triangle when the lengths of all three sides are known. Let s1 , s2 and s3
be the lengths of the sides. Let s = (s1 + s2 + s3 )/2. Then the area of the triangle
can be calculated using the following formula:

area = s × (s − s1 ) × (s − s2 ) × (s − s3 )

Develop a program that reads the lengths of the sides of a triangle from the user and
displays its area.

Exercise 23: Area of a Regular Polygon


(Solved, 14 Lines)
A polygon is regular if its sides are all the same length and the angles between all of
the adjacent sides are equal. The area of a regular polygon can be computed using
the following formula, where s is the length of a side and n is the number of sides:
1.6 Exercises 19

n × s2
area = π 
4 × tan
n
Write a program that reads s and n from the user and then displays the area of a
regular polygon constructed from these values.

Exercise 24: Units of Time


(22 Lines)
Create a program that reads a duration from the user as a number of days, hours,
minutes, and seconds. Compute and display the total number of seconds represented
by this duration.

Exercise 25: Units of Time (Again)


(Solved, 24 Lines)
In this exercise you will reverse the process described in Exercise 24. Develop a
program that begins by reading a number of seconds from the user. Then your program
should display the equivalent amount of time in the form D:HH:MM:SS, where D,
HH, MM, and SS represent days, hours, minutes and seconds respectively. The hours,
minutes and seconds should all be formatted so that they occupy exactly two digits.
Use your research skills determine what additional character needs to be included in
the format specifier so that leading zeros are used instead of leading spaces when a
number is formatted to a particular width.

Exercise 26: Current Time


(10 Lines)
Python’s time module includes several time-related functions. One of these is the
asctime function which reads the current time from the computer’s internal clock
and returns it in a human-readable format. Use this function to write a program that
displays the current time and date. Your program will not require any input from the
user.

Exercise 27: When is Easter?


(33 Lines)
Easter is celebrated on the Sunday immediately after the first full moon following the
spring equinox. Because its date includes a lunar component, Easter does not have
a fixed date in the Gregorian calendar. Instead, it can occur on any date between
20 1 Introduction to Programming

March 22 and April 25. The month and day for Easter can be computed for a given
year using the Anonymous Gregorian Computus algorithm, which is shown below.
Set a equal to the remainder when year is divided by 19
Set b equal to the floor of year divided by 100
Set c equal to the remainder when year is divided by 100
Set d equal to the floor of b divided by 4
Set e equal to the remainder when b is divided by 4
b+8
Set f equal to the floor of
25
b− f +1
Set g equal to the floor of
3
Set h equal to the remainder when 19a + b − d − g + 15 is divided by 30
Set i equal to the floor of c divided by 4
Set k equal to the remainder when c is divided by 4
Set l equal to the remainder when 32 + 2e + 2i − h − k is divided by 7
a + 11h + 22l
Set m equal to the floor of
451
h + l − 7m + 114
Set month equal to the floor of
31
Set day equal to one plus the remainder when h + l − 7m + 114 is divided
by 31

Write a program that implements the Anonymous Gregorian Computus algorithm


to compute the date of Easter. Your program should read the year from the user and
then display a appropriate message that includes the date of Easter in that year.

Exercise 28: Body Mass Index


(14 Lines)
Write a program that computes the body mass index (BMI) of an individual. Your
program should begin by reading a height and weight from the user. Then it should
use one of the following two formulas to compute the BMI before displaying it. If
you read the height in inches and the weight in pounds then body mass index is
computed using the following formula:

weight
BMI = × 703
height × height

If you read the height in meters and the weight in kilograms then body mass index
is computed using this slightly simpler formula:

weight
BMI =
height × height
Discovering Diverse Content Through
Random Scribd Documents
"And see the rivers how they run
Through woods and meads, in shade and sun,
Sometimes swift, sometimes slow,—
Wave succeeding wave, they go
A various journey to the deep,
Like human life to endless sleep!"

TRENTON FALLS.
In the hills north of Utica, the West Canada Creek cuts its
remarkable gorge at Trenton Falls. It is a vigorous stream, rising in
the western slopes of the Adirondacks and flowing to the Mohawk.
In getting down through the limestone rocks from the highlands to
the plain adjacent to the river, it passes into the ravine, giving a
magnificent display of chasms, cascades and rapids, in a gorge of
such amazing construction that it is regarded as a wonder second
only to Niagara. During the ages, the torrent has cut through over
four hundred layers of the stratified limestone, exposing the
geological formation to full view, with the fossil organic remains
deposited there as the world was built. In descending the ravine,
there are five prominent cataracts, besides rapids, all compressed
within two miles distance, the aggregate descent being three
hundred and twelve feet. This wonderful gorge was the Indian Kauy-
a-hoo-ra, or the "Leaping Water," and from its color they called the
stream Kahnata, the "amber water," a name readily corrupted into
Canada Creek. The Dutch called the place after the Grand Pensioner
of Holland, Oldenbarneveld, he having sent out the first colonists
under a grant known as the "Holland Patent." It was in this region
Grover Cleveland spent his early life. A grandson of Roger Sherman,
who had charge of the Unitarian church here, is regarded as the
discoverer of the ravine in 1805, and he did much to make it known
to the world. His grave is within sound of the Sherman Fall.
Entering the chasm at the lower end, where the stream passes out
from the rock terrace to the plain, the ravine is found to be about
one hundred feet deep, the almost perpendicular rocky walls built up
in level layers as if by hands, the well-defined separate strata being
from one inch to a foot in thickness, and narrowest at the bottom.
Hemlocks and cedars crown the blackened rocks, their branches
hanging over the abyss, while far below, the boisterous torrent
rushes across the pavement of broad flagstones forming its bed.
Descending to the bottom, the impression is like being in a deep
vault, this subterranean world disclosing operations lasting through
ages, during which the rocks have slowly yielded to the resistless
power of the water and frost that has gradually cut the chasm.
Fossils and petrifactions found in the deepest strata are trod upon,
and each thin layer of the walls, one imposed upon the other, shows
the deposit of a supervening flood happening successively, yet
eternity only knows how long ago. And ages afterwards the torrent
came, and during more successive ages carved out the gorge, until it
has penetrated to the bottom of the limestone.
The torrent flows briskly out of the long and narrow vault, while
some distance above is the lowest of the series of cataracts—the
Sherman Fall—where the water plunges over a parapet of rock forty
feet high into a huge basin it has worked out. The amber-colored
waters boil furiously in this cauldron. Above the Sherman Fall the
stream flows through rapids, the chasm broadening and the lofty
walls rising higher as the hill-tops are more elevated, mounting to
two hundred feet above the torrent at a lofty point called the
Pinnacle. The floor of the ravine is level, and becomes quite wide,
with massive slabs, weighing tons, resting upon it, showing the
power of freshets which bring them down from above, and will
ultimately carry them completely through the gorge to its outlet, so
resistless is the sweep of the raging flood at such times, when every
bound these huge stones make over the rocky floor causes the
neighboring hills to vibrate, the stifled thunder of their progress
being heard above the roar of waters. At the head of this widened
gorge is the High Falls, in a grand amphitheatre, the cataract broken
into parts and combining all the varieties of cascade and waterfall,
being one hundred feet high, and the walls of the chasm rising
eighty feet higher to the surface of the land above, which keeps on
rising as the ends of the limestone strata are surmounted. The top
of this High Fall is another perpendicular wall stretching diagonally
across the chasm, and below it the protruding layers of rock form a
sort of huge stairway. Down this the waters fall in varying fashion,
finally condensing as a mass of whirling, shifting foam into a dark
pool beneath. This splendid cataract is fringed about with
evergreens and shrubbery, for between the dark thin slabs of
limestone are inserted thinner strata of crumbling shale, and these
give root-hold to the cedars and other nodding branches clinging to
the walls of the ravine. The waterfall begins at the top with the color
of melted topaz, and is unlike anything elsewhere seen, for the
hemlocks and spruces of the mountain regions impart the amber
hue to the torrent. Descending, the changing tints become steadily
lighter, until the brown turns to a creamy white, which is finally lost
under the cloud of spray at the foot of the lower stairway slide, while
beyond, the water rushes away black in hue and driving forward
almost as if shot from a cannon.
Above is another great amphitheatre, floored with rocky layers, upon
which the stream flows in gentler course. In this is the Milldam Fall,
a ledge about fourteen feet high, over which the waters make a
uniform flow all across the ravine. This has above it an expanded
platform of level slabs almost a hundred feet wide, fringed on each
side with cedars, the attractive place being called the Alhambra. At
the upper end a naked rock protrudes about sixty feet high, from
which a stream falls as a perpetual shower-bath. The creek rushes
down another complex stairway in the Alhambra Cascade. The
ravine above suddenly contracts, and the walls beyond change their
forms into shapes of curves and projections. Another cascade of
whirling, foaming waters is passed, and a new amphitheatre
entered, where great slabs of rock have fallen from the walls and lie
on the floor, ready to be driven down the ravine by freshets. The
torrent here develops another curious formation, known as the
Rocky Heart. Curved holes are being rounded out by whirling
boulders of granite, which are kept constantly revolving by the
running water, and thus readily act upon the softer limestones. The
chasm goes still farther up to the Prospect Falls, a cataract twenty
feet high, near the beginning of the ravine.
Canada Creek passes out of the lower end of the gorge, where the
limestone layers are exhausted, and their edges fall off in terraces
sharply to the lower level, and almost down to the surface of the
stream. All about the broadened channel, as it flows away towards
the Mohawk, lie the huge slabs and boulders driven down through
the chasm by repeated freshets, with the amber waters foaming
among them. This wonderful ravine is a geological mine, disclosing
the transition rocks, the first containing fossil organic remains. In the
lower part of the chasm they are compact carbonate of lime,
extremely hard and brittle, and a dark blue, almost black, in color. At
the High Fall, and above to the Rocky Heart, the upper strata are
from twelve to eighteen inches thick, and composed of the
crystallized fragments of the vertebræ of crinoidea and the shells of
terebratulæ. These fossils of the Silurian period are numerous. The
strata throughout the chasm are remarkably horizontal, varying, as
they ascend, from one inch to eighteen inches in thickness. They are
very distinct, and separated by a fine shaly substance which
disintegrates upon exposure to the air or moisture. From the top to
the bottom of the ravine small cracks extend down perpendicularly,
and run in a straight line through the whole mass across the stream.
These divide the pavements into rhomboidal slabs. The most
interesting fossils are found, among them the large trilobite, a
crustacean that could both swim and crawl upon the bottom of the
sea. This extraordinary place is in reality a Titanic fissure, cracked
through the crust of mother earth, down which roars and dashes a
tremendous torrent.

THE LAKES OF NEW YORK.


The northwestern boundary of the State of New York is formed by
Lake Ontario, of which the St. Lawrence River is the outlet, flowing
northeastward into Canada. Ontario is the smallest and the lowest in
level of the group of Great Lakes, its name given by the Indians
meaning the "beautiful water." It is about one hundred and eighty
miles long, and its surface is two hundred and thirty-one feet above
tide, but it is fully five hundred feet deep, so that it has more depth
below the ocean level than the lake surface is above. It has a
marked feature along its southern shore, where a narrow elevation
known as the "Lake Ridge" extends nearly parallel with the edge of
the lake, and from four to eight miles distant. The height of this
ridge usually exceeds one hundred and sixty feet above the lake
level, and in some places is nearly two hundred feet, and it is,
throughout, from five to twenty feet above the immediate surface of
the land, there being a width at the summit of some thirty feet, from
which the ground slopes away on both sides. This ridge is regarded
as an ancient shore-line formed by the waters of the lake, and the
chief public highway on the southern side of the lake is laid for many
miles along its summit. The main tributaries of Ontario from New
York are the Black, Oswego and Genesee Rivers. The Black River
gathers various streams draining the western slopes of the
Adirondacks, and its name comes from the dark amber hue of the
waters. It flows northwest through a forest-covered region, pours
down Lyons Falls, a fine cataract of seventy feet, passes the
manufacturing towns of Lowville and Watertown, and finally
discharges by the broadened estuary of Black River Bay into the east
end of Lake Ontario. From Rome, on the Mohawk, a canal is
constructed northward to the Black River.
Westward from Rome the land is an almost level plain, rising into the
Onondaga highlands to the southward. Cazenovia Lake, among
these hills, sends its outlet northward over the plain to Oneida Lake.
There are various little lakelets between, but the ground is
impregnated with sulphur, so that their waters are bitter, and one is
consequently named Lake Sodom. Oneida is a large lake, twenty-
three miles long and several miles broad, with low and marshy
shores. In the fertile dairy region to the southeastward is located the
"Inspiration Community" of Oneida, founded in 1847 by John
Humphrey Noyes, a Vermont preacher. In 1834, when twenty-three
years old, he experienced what he called a "second conversion," and
announced himself a "perfectionist." He preached his new faith and
finally established the Oneida Community for its demonstration, with
about three hundred members. They maintain the perfect equality of
women with men in all social and business relations, and have
become quite wealthy as manufacturers, farmers and dairymen. The
outlet of Oneida Lake, and in fact the outlet streams of all the lakes
of Central New York, discharge into Oswego River, which flows
northward into Lake Ontario. Oswego means "the small water
flowing into that which is large," and the port at its mouth, noted for
its flour and starch-mills, has about twenty-five thousand people,
and is the largest city on the New York shore of Lake Ontario. This
was an early French settlement in the seventeenth century, when
the river was known by them as the "river of the Onondagas."
The great plain south of Lake Ontario, which is believed to have
been itself formerly a lake bed, rises into highlands farther
southward, and the noted group of lakes of Central New York are
scattered in the valleys which are deeply fissured into these
highlands. Most of these lakes are long and narrow, and they nestle
in almost parallel valleys, their waters occupying the bottoms of
deep ravines. These lakes present much fine scenery, and their
shores are among the most attractive parts of New York. They
display vineyards and fruit orchards and extensive pastures, and
their present names are the original titles given them by the
Iroquois, many of whom still live on reservations near them.
Southwest of Oneida is Onondaga Lake, and farther west
Skaneateles and Owasco. Then beyond is the larger Cayuga Lake,
and to the westward Seneca, the largest of the group, sixty miles
long, elevated two hundred feet above Lake Ontario, and of great
depth, estimated to exceed six hundred feet. This lake was never
known to be frozen over but once, and that was late in March many
years ago; steamboats traverse it every day in the year. Cayuga Lake
is of similar character, but of slightly less size and elevation, and in
some places is so deep as to be almost unfathomable. These parallel
lakes are separated by an elevated ridge only a few miles wide, and
their great depth, descending much below the level of Ontario, into
which they discharge, gives evidence to the geologists that their
waters originally drained to the southward. Westward of Seneca is
Keuka or the Crooked Lake, the Indian name meaning "the lake of
the Bended Elbow." It is a pretty sheet of water, having an angle in
its centre, from which starts out another long and narrow branch, so
that its spreading arms make it look much like the aboriginal
signification. It is elevated two hundred and seventy-seven feet
above the level of Seneca Lake, which is only seven miles away.
Beyond Keuka is Canandaigua Lake, the westernmost of the group.

THE SYRACUSE SALT-MAKERS.


Onondaga Lake is comparatively small, being six miles long and
about a mile broad, and it is noted for its salt wells, which have
made the prosperity of the city of Syracuse, the largest in Central
New York, built along Onondaga Creek south of the lake, and upon
the slopes of the higher hills to the eastward. An Indian trader
started the town in the eighteenth century, and soon afterwards Asa
Danforth began making salt at Salt Point on the lake, calling his
village Salina. When the Erie Canal came along the place grew
rapidly, and it is now a great canal and railroad centre, with lines
radiating in various directions, and from it the Oswego Canal goes
northward to Lake Ontario. The city has a population approximating
a hundred thousand. The salt springs come out of the rocks of the
Upper Silurian period, and are located chiefly in the marshes
bordering Onondaga Lake. The brine wells are bored in the lowlands
surrounding the lake to a depth of two hundred to over three
hundred feet. The State of New York controls the wells and pumps
the brine to supply the evaporating works, which are private
establishments, a royalty of one cent per bushel being charged. The
main impurity that has to be driven out of the brine is sulphate of
lime, and the finer product has a high reputation, the "Onondaga
Factory-Filled Salt" being greatly esteemed. The salt wells were
known to the Indians, and the French Jesuit missionaries found
them as early as 1650, taking salt back to Canada. In 1789 they
yielded five hundred bushels, and they have since produced as high
as nine millions of bushels a year, the annual product now being
about three millions. The brine is first pumped into small shallow
vats, where it remains until the carbonic acid gas escapes and the
iron is deposited as an oxide. It is then led to the evaporating vats,
all processes being used, solar as well as boiling. The land bordering
the marshy shores of Onondaga Lake is framed around by rows of
factories and heating furnaces, while out on the marshes are clusters
of little brown houses, each covering a well and pump. From there
the brine is led through conduits made of bored logs, called the "salt
logs," to the evaporating vats and factories, some going long
distances. Everything throughout the whole district is profusely
saturated with salt.
Syracuse is one of the handsomest cities of the Empire State. The
New York Central Railroad passes through the centre of the business
section, the locomotives and ordinary traffic sharing the main street
in common, in front of the chief hotels and stores, for thus has the
town grown up. Just northward, the Erie Canal also goes through
the heart of the city, giving on moonlight nights scenes that are
almost Venetian. The streets are broad, and ornamental squares are
frequent, the chief residential highways—James, Genesee and
University Streets—being bordered with imposing dwellings
surrounded by extensive grounds. Magnificent trees line the streets
and broad lawns stretch back to the dwellings, everything being
open to public view, so that in these parts the town is practically a
vast park. To the eastward rises University Hill, crowned by the
buildings of Syracuse University, a Methodist foundation having
eleven hundred students. Holden Observatory adjoins the grand
graystone main college building, and from this high hill there is a
magnificent view over the city and the oval-shaped lake and its salt
marsh border off to the northwest. The southern view is enclosed by
the Onondaga highlands, out of which Onondaga Creek comes
through a deep and winding valley. Back among these dark blue
distant hills still live in pastoral simplicity the remnants of the "Men
of the Mountain,"—the Onondagas,—the ruling power of the famous
Iroquois Confederation.

AUBURN, ITHACA AND CORNELL.


Westward from Syracuse the country is full of lakes. Otisco Lake,—
the "Bitter-nut Hickory,"—is an oval four miles long, embosomed in
hills. To the northwest of Otisco is Skaneateles Lake—the "Long
Water"—the most picturesque of all, set among most imposing hills,
which, notwithstanding the lake is elevated eight hundred and sixty
feet, still rise twelve hundred feet above its surface, giving the
waters the deeply blue tinge of an Italian scene. This lovely lake is
sixteen miles long, and in no place more than a mile and a half wide,
its outlet having a fine cataract. To the westward is Owasco Lake
—"the bridge on the water floating"—eleven miles long and a mile
wide, walled in by rocky bluffs, yet having its shores diversified by
meadows and farm land. About two miles northward, on its outlet, is
the busy manufacturing city of Auburn, with thirty thousand people,
which was the home of William H. Seward, Governor and Senator
from New York, who was President Lincoln's Secretary of State
during the Civil War. Its most extensive establishment is the Auburn
Prison, covering about eighteen acres, enclosed by walls four feet
thick and twelve to thirty-five feet high, there being imprisoned
usually about twelve hundred convicts. The surface of the city is
varied by hills, making handsome villa sites, and the Owasco Lake
outlet flows down a series of rapids, falling one hundred and sixty
feet, and utilized by no less than nine dams to turn the wheels of
many mills. Captain Hardenburgh was the first settler here in 1793,
the original name being "Hardenburgh's Corners." On Fort Hill, one
of the highest elevations, the top of which is supposed to be an
eminence originally raised by the ancient Mound-Builders, and was
an Iroquois fortification, is the Cemetery where are interred the
remains of William H. Seward, who died in 1872.
After crossing a rich grazing country, farther to the westward is
Cayuga Lake—the name meaning "Where they take canoes out"—
stretching from the level plain of Central New York southward into
the highlands, making the watershed between the affluents of the
St. Lawrence and the Susquehanna. Progressing southward along
the long and narrow lake, the hills are found to grow steadily higher,
and they reach an elevation of several hundred feet above its
surface. The bordering rocky buttresses rise up as columns and
walls, with accurately-squared corners, their perpendicular
stratification making the flagstone layers that have been loosened by
the frost stand on edge and separately, seeming almost ready to
topple over, while heaps of broken fragments are strewn at their
bases, which, being pulverized by the action of frost and water into
small particles, produce a smooth and narrow beach. At the head of
the lake the deep valley is prolonged farther southward between
even higher enclosing ridges, the Cayuga Inlet winding through it.
Here, about a mile from the lake, is a flourishing town of twelve
thousand people, reproducing the name of the Ionian Island that
was the fabled kingdom of Ulysses—Ithaca. It is the centre of a
grazing region, producing cheese, butter and wool, and its water-
power has given some manufacturing activity, but it is chiefly known
to fame from the surrounding galaxy of waterfalls and the
possession of Cornell University.
Cayuga Lake, at its head, has a rugged verge, and in the glens and
gorges descending four to five hundred feet from the hills to the lake
and its prolonged southern valley, are some of nature's most
beautiful sanctuaries. Fall Creek has eight cataracts within a mile, all
of them charming. It comes tumbling down the Triphammer Fall into
a basin, then over one cascade after another until it plunges down a
foaming precipice and finally goes over the Ithaca Fall, one hundred
and sixty feet high and about as wide. Alongside the lake, near the
outlet of this brook, are remarkable formations,—Tower Rock, a
perfect columnar structure forty feet high, and Castle Rock, a
massive wall with a grand arched doorway opened through it—both
strange freaks of nature. The ravine of Cascadilla Creek to the
southward is also filled with cascades, and on an elevated plateau
between the two gorges is Cornell University. The most noted
waterfall of Cayuga is the Taghanic—the original Indian word
meaning "Water enough." A stream flows in from the western hills a
short distance north of Ithaca, and the fall is two hundred and
fifteen feet high and some distance back in the ridge. Its interesting
features are the great height, the very deep ravine and its sharply-
defined outlines, and the splendid views; and its admirers regard it
as a worthy rival of the much-praised Swiss Staubbach. The water
breaks over a cleanly-cut table-rock, falls perpendicularly, and
excepting in freshets, it changes into clouds of spray before reaching
the bottom. The rocky enclosing walls rise four hundred feet high
around it, being regularly squared as if laid by human hands, and
this is the highest American waterfall east of the Rockies.
High above Ithaca, standing upon the brow of the ridge making its
eastern border, are the imposing buildings of Cornell University,
devoted to the free education of both sexes in all branches of
knowledge, the spreading college campus elevated four hundred feet
above the lake. Here are educated eighteen hundred students, who
have about one hundred and eighty instructors. The College of
Forestry, established in 1898, is the only one in the country. The
University has munificent endowments, becoming constantly more
valuable, as lands of steadily increasing worth are among the
holdings, the aggregate being estimated at $8,000,000. At the edge
of Ithaca is the mansion which was the home of Ezra Cornell the
founder, who amassed a fortune mainly in telegraphy, he then being
at the head of the Western Union Company. To his generosity was
added the proceeds of the ample school lands of New York State,
the gift of the Federal Government, which he selected with
scrupulous care, and these gave the University its start. He died in
1874. Others gave supplementary gifts. John McGraw of Ithaca gave
McGraw College, the central building on the campus, two hundred
feet long, with a tower rising one hundred and twenty feet,
containing the great University bell with full chimes, and having a
view forty miles northward along the lake and almost half as far
southward through the deep valley. This structure is flanked by the
North and South University buildings, each one hundred and sixty-
five feet long, all three substantially constructed of dark blue stone
with light gray limestone trimmings. There are also the Sibley
Building, and the magnificent Cascadilla Hall, nearly two hundred
feet long, which is a residence for instructors and students. The
Sage College for females and other handsome buildings adorn the
campus, including an armory, for everything is taught, and a battery
of mounted cannon guards the approach to the grounds.

HAVANA AND WATKINS GLENS.


Seneca Lake, the largest of the group, is a short distance west of
Cayuga, and its prolonged southern valley is bordered by ridges
rising even higher, through which the streams have carved
remarkable gorges. Two of the larger torrents coming into the
prolonged Seneca Valley have hewn out of the hillsides, one on
either hand, romantic fissures of wide renown,—the Havana and
Watkins Glens. The Havana Glen is three miles south of the lake and
about a mile long, being cut out of the eastern wall of the valley.
The ravine is steep, having quite a large stream. Its characteristic is
that the water and frost have made great fissures and caverns, but
so fashioned them that all the joints and corners are right-angles.
The cascades are successions of ledges, the water apparently
running down a staircase. If the stream runs over a waterfall, it
comes from a level ledge as if running over a wall. If it rushes
through a gorge, all the corners are square, the sides perpendicular
and the bottom level. If a brigade of stonemasons had built the
place it could hardly have been more accurately constructed. Several
of the cascades are magnificent, the "Bridal Veil" and the "Curtain
Falls" going down a maze of rocky ledges, their frothy waters making
resplendent sheets of exquisite lacework. In one place the stream
flows through a perfectly square grotto known as the "Council
Chamber," entering this great hall by a right-angled bend from an
adjoining square-cut grotto of similar character. Each is a perfect
apartment, the water rushing from one to the other through an
entry-like passage, from which it makes a square turn. The glen is
quite steep, and its "Central Gorge" is a narrow fissure, clean-cut
and deep, making a half-dozen right-angled bends, each lower than
the other, the torrent rushing around the sharp corners and over the
straight edges with wild swiftness and clouds of spray. The visitor
mounts ladders and steps through the spray, and the glen can be
followed a long distance upward past many cascades, its
picturesqueness being enhanced by the huge tree-trunks the torrent
occasionally brings down and lodges in the many angular bends.
Watkins Glen

Watkins Glen, carved out of the western wall of the valley just at the
head of Seneca Lake, is constructed upon a grander scale, yet
entirely different. The torrent has hewn it among similarly laminated
rocks, but the erosive processes have made vast amphitheatres,
their great size dwarfing the diminutive brook flowing like a thread
at the bottom. The entrance, level with the floor of the valley,
presents the same squared and angular features as Havana Glen,
but inside it is a grand amphitheatre enclosed within perpendicular
stone walls three hundred feet high, and is proportionately spacious.
It is quickly seen, however, that within the grand hall the rocky
layers, instead of being squared and angular, have been smoothed
and rounded by the waters, the small but dashing stream flowing
over the floor by graceful curves through circular pools and winding
channels. This glen is built on a prodigious scale, being over three
miles long, and its head rising eight hundred feet above the valley. A
narrow cascade eighty feet high falls at the far end of the entrance
amphitheatre, and climbing up, the visitor enters "Glen Alpha," the
first of the vast chambers. There are successive glens and caverns
as one proceeds onward and upward through the "Cavern Gorge"
and "Glen Obscura," where a hotel and chalet are perched on the
rocky ledges at four hundred feet elevation. Above is the "Sylvan
Gorge," and then the fissure broadens out into its grandest section,
the "Glen Cathedral," a magnificent nave, with walls rising nearly
three hundred feet, the rocky layers giving it a level stone floor. It
has the "Pulpit Rock" and "Baptismal Font," and climbing out one
hundred and seventy feet upward alongside a cascade, the visitor
then goes onward past more grottoes, falls and gorges for a long
distance, until the "Glen Omega" is reached at the top. Here an airy
railway bridge of one of the Vanderbilt roads spans it at two hundred
feet height above the floor.
The shores of Seneca Lake, as one progresses northward, present
various pretty little glens cut deeply into the bordering hills, and as
these become lower there are vineyards and pastures displayed.
Gradually the bluffs disappear, giving place to extensive farm lands
as the level plain at the outlet is reached. Here, in imitation of a
noble Swiss example, the town of Geneva has been built at the foot
of the lake, its chief street extending along the western bank, with
villas peeping out from the foliage. This is a prominent nursery town,
florists and seedsmen being its chief merchants, and a large part of
the adjacent country being devoted to seed-growing and
propagation. Hobart College, a leading Episcopal foundation, is at
Geneva. The outlet of the lake is the Seneca River, having an
attractive waterfall, and after gathering the outflow of this group of
Central New York lakes, it goes away northeastward to Oswego
River.

CANISTEO AND CHEMUNG RIVERS.


There are yet two other lakes westward of Seneca, Keuka and
Canandaigua. This region was generally first peopled by the
Puritans, but others also came in, and at the outlet of Keuka is the
town of Penn Yan, so called from the Pennsylvanians and Yankees
who settled it, their descendants being the shrewd and thrifty race
known as the "New York Yankees." There are extensive vineyards on
Keuka where are made some of the best American clarets and
champagnes, the centre of that industry being Hammondsport, at
the head of the lake. Beyond is Canandaigua Lake, the town of
Canandaigua standing at its northern end upon a surface gently
sloping towards its shores. The word means the "place chosen for a
village." The heads of all these lakes are in the southern highlands,
making the watershed, south of which the streams are gathered into
the Canisteo River, meaning "the board on the water," which flows
into the Chemung, the "big horn," and thence by the Susquehanna
down through Pennsylvania to the Chesapeake. The Erie Railway,
coming eastward by a wild and lonely route across the Allegheny
ranges, goes down the pretty Canisteo Valley to Hornellsville, a
purely railroad town of twelve thousand people, which has grown up
around the shops and stations. Below, the valley broadens, and is
picturesque between its high bordering ridges, the stream
meandering in wayward fashion over the almost flat intervale. It
passes Addison and the town with the unique name of Painted Post,
so called from an Indian monument inscribed in colors, and as the
Canisteo River broadens with the contribution of its swelling
tributaries, it reaches the active manufacturing city of Corning,
having ten thousand people, and here falls into the Chemung, which
comes up northward out of the Allegheny ranges in Pennsylvania to
meet it. The Chemung Valley is a broad and fertile section of flat and
highly cultivated bottom lands, having in its heart the city of Elmira,
with thirty-five thousand inhabitants and many industrial
establishments, making it a busy railroad centre. Here is the Elmira
Reformatory, the Elmira Female College, and the various "Water
Cures," a species of remedial establishment flourishing throughout
Western New York, where there is apparently no limit to the efficacy
or bountifulness of the water-supply. The broad Chemung flows
through Elmira and beyond down its rich and wide-spreading valley,
until at Athens it loses itself in the swelling waters of the
Susquehanna.

THE VALLEY OF THE GENESEE.


Among the rugged mountains of Potter County, in the northern part
of Pennsylvania, the highest land in the State, are the springs
feeding the headwaters of three noted rivers, seeking the ocean in
opposite directions. The Allegheny flows westward and afterwards
southward to the Ohio; the west branch of the Susquehanna goes
eastward to break through the entire Allegheny chain in seeking the
Atlantic; and the smaller stream, the Genesee, flows northward
through New York between two long Allegheny ridges, the chief
affluent of Lake Ontario. The Genesee passes through a valley of
great beauty and gives water-power to many mills, a canal also
being constructed to improve its navigation. After a romantic course
of one hundred and fifty miles it empties into the lake at Charlotte,
seven miles north of Rochester. For much of the distance its course
is through a magnificent gorge, with a succession of cataracts that
are renowned in American scenery. Where it first attacks the
highlands of New York to break out of them, it plunges deeper and
deeper down a series of grand cataracts at Portage. Here the Erie
Railway, coming from the westward, has boldly thrown a stupendous
bridge across the tremendous chasm and almost over the top of the
highest cataract. The river makes a gorge in the yielding rocks,
sinking from two hundred and fifty to six hundred feet deep, and
here are the Portage Falls, one cataract after another making the
stream-bed lower, the walls of the wild ravine rising almost
perpendicularly. The railway, crossing at the most favorable place,
has built one of the highest bridges in the country, elevated two
hundred and thirty-five feet above the river, resting upon lightly-
framed steel trusses. From the car windows the river can be seen far
below in what seems a narrow fissure, the current boiling along and
then tumbling down the cataract, the edge of which crosses the river
diagonally almost beneath the bridge. The waters pour into a chasm
seeming almost bottomless as the spray obscures it. The ravine
extends northward, and in the distance the waters go over a second
fall and then a third, the chasm finally curving around to the right,
making a bend, closing the view more than a mile away, with an
enormous wall of bare rock. The three cataracts fall respectively
seventy, one hundred and ten and one hundred and fifty feet—called
the Upper, Middle and Lower Portage Falls—and for several miles
below, the river flows through the deeper ravine amid equally
magnificent surroundings.
This descent brings the Genesee River down from the higher plateau
to what is known as the "Genesee Level," for at the end of the
defile, fifteen miles below Portage, it flows out of the highlands over
pleasant lands and with gentler current. Here on the "Genesee Flats"
is the village of Mount Morris, and near it has been placed, alongside
the ravine, the rude log cabin, which was originally on the higher
land above Portage, the Indian "Council House of Cascadea," where
the Iroquois chiefs often met. At the removal in 1872, the services
were conducted in the Senecas language, several Indians attending,
and the identical "pipe of peace" given by Washington to Red Jacket
was passed around. Nearby the river emerges through a Titanic
gateway in the rocks to the pastoral region stretching far to the
northward, while far over on the eastern verge is the village of
Geneseo, sloping up the ascent. Its Indian name, meaning the
"beautiful valley," is also given the river. After meandering placidly
for miles across these flats, the Genesee River reaches the "Flour
City of the West," Rochester, the storage and distributing mart for
this fertile valley, getting its original start and title from the prolific
wheat crops. And here the Genesee plunges down another waterfall
which gives power to the Rochester mills.
When De Witt Clinton, in 1810, exploring the route for the Erie
Canal, crossed the river here, there was not a house. The place was
afterwards the "Hundred Acre Tract," planned in 1812 for a
settlement by three adventurous frontiersmen, and the town was
named for one of them, Nathaniel Rochester. After a few years, the
spreading fame of the fertility of the Genesee Valley attracted a large
population, and it became known as the garden spot of the then
"West," so that out of this grew the flour-mills which have continued
to be Rochester's chief industry. The Genesee River flows through
with swift current, the Erie Canal being carried over on a massive
stone aqueduct and the New York Central Railroad upon a wide
bridge, and about a hundred yards beyond, the river plunges down
the great Rochester Fall. The ledge over which it tumbles is a
perpendicular wall, straight and regular in formation, and almost
without fragments of rock at the foot, so that the fall is a clear one.
The shores below are lined with huge stone mills and breweries, to
which races on each bank conduct the water from a dam above the
railroad bridge. This Rochester Fall, down which Sam Patch jumped
to his death, is ninety-six feet high. Below it, the river flows through
a somewhat wider channel, gradually bending to the left, and then it
goes down a second cataract of twenty-five feet height, and finally,
at some distance, over a third and broken fall of eighty-four feet. As
at Portage, this second succession of triple cataracts sinks the river
bed deeper and deeper into the gorge, so that the enclosing walls
are in some places over three hundred feet high. This gorge is all
within the limits of the city, the falls and rapids having a total
descent of two hundred and sixty feet. This immense water-power,
with the traffic facilities of canal and railway, have made the city, so
that there is a population of a hundred and forty thousand around
the Genesee Falls, and manufactures of flour, beer, clothing, leather
and other articles, valued at $75,000,000 annually. In the
neighboring region there is also extensive seed-growing, the
Rochester nurseries occupying miles of the level surface. Rochester
University has two hundred students and valuable geological
collections. The city has been a headquarters for the Spiritualists and
advocates of Women's Rights. The Genesee emerges from the rocky
gorge below Rochester, and flows in more tranquil course northward
through a ravine carved deeply into the table-land, to Lake Ontario,
at the little port of Charlotte.

LOCKPORT, CHAUTAUQUA AND ERIE.


Westward from Rochester the country is underlaid by red
sandstones, and at Medina quarries are plentiful, this reproduction of
the Arabian "City of the Prophet" being an extensive supplier of
these dark-red Medina sandstones, as the geologists call them.
Beyond, at Lockport, the higher terrace is reached, and here the Erie
Canal is raised by an imposing series of five double locks from the
Genesee level up to the Lake Erie level. Through these locks and by
means of a subsidiary canal an immense water-power is obtained
which is utilized by the Lockport mills. The much lower Genesee
level is marked by the base of a bluff, stretching through the town
and across the adjacent region, evidently the bank of an ancient
lake.
In western New York a high ridge crosses the country south of Lake
Erie, and to the southward of its most elevated portion there
stretches the elongated Chautauqua Lake, almost bisected by two
jutting points at its centre. This charming lake is eighteen miles long,
three or four miles wide, and elevated seven hundred and thirty feet
above Lake Erie, its outlet draining southward into a tributary of the
Allegheny River. Its elevation above tide is nearly thirteen hundred
feet. The low hills enclosing it are popular summer resorts, and on
the western bank in the season are drawn enormous crowds to the
Chautauqua Assembly, which has established the "Summer School of
Philosophy" for education. There are often twenty to thirty thousand
people here at one time, and the plan has been so successful that it
has various imitators elsewhere, the "Chautauqua idea" being
varying instruction with recreation. The Indians named this lake,
from the mists arising, Chautauqua, or "the foggy place." Beyond
this popular resort the land falls away, and crossing the New York
western boundary into the "Pennsylvania Triangle," a jutting corner
thrust up to Lake Erie, a fine harbor is found at Erie, known in earlier
history by its French name of Presque Isle. This triangle of the
Keystone State, giving about forty miles of coast-line on the lake,
has a history. The early surveyors discovered that, owing to
misdescriptions in various English grants, this large triangular tract
was, from a legal standpoint, "nowhere." It was north of
Pennsylvania, west of New York and east of the Connecticut Western
Reserve, which became part of Ohio. Pennsylvania finally bought it,
paying the United States Government, in 1792, $150,640 for it, and
also getting the Indian title for £1200. It was a good purchase, for
Erie harbor is the best on the lake. Erie has about fifty thousand
people, and is in a picturesque situation, owing to the beauty of the
bay and the outlying island, which was formerly a peninsula. There
is additional protection by a breakwater, making an extensive basin
with spacious docks that have a large trade. The French were the
early settlers, building their "Fort de la Presque Isle" in 1749, which
was one of the chain of outposts they projected between the St.
Lawrence and the Ohio. It was here that Commodore Perry hastily
built the rude fleet with which he gained the noted victory over the
Anglo-Canadian fleet on Lake Erie in 1813, and back here he
afterwards in triumph towed his prizes. The remains of his flagship
lie in the harbor. Perry's guns were the heaviest in that memorable
contest for control of the lake, and therefore he won. In Lake Side
Cemetery is buried Captain Charles Vernon Gridley, who commanded
Admiral Dewey's flagship, the "Olympia," at the battle of Manila Bay
in 1898.

THE CITY OF BUFFALO.


Dunkirk, in New York, northeast of Erie, is another harbor on the
lake, and a terminal of the Erie Railway, the land hereabout being
the monotonous level plain of western New York. Rounding the
eastern end of Lake Erie, at the head of its outlet stream, the
Niagara River, is Buffalo, the chief port of the lake and the
metropolis of western New York. It is surrounded for miles upon the
level land with railway terminals and car-yards, amid which factories,
breweries, coal-pockets, cattle-pens and grain elevators are
distributed. This great city, which has grown to four hundred
thousand population, takes it name from the American bison, who
roamed in large herds over the lands adjacent to Lake Erie as late as
1720, and thus gave the name to Buffalo Creek. The city covers a
broad surface at the foot of Lake Erie, and is coeval with the
nineteenth century, having been founded in 1801; but in the earlier
years it was only a military post, and did not assume a commercial
standing or begin to grow much until after the opening of the Erie
Canal. The neighboring post of Niagara, a short distance down that
river, was of more importance in the early days of the frontier, for it
was on Niagara River, in 1669, that the Sieur de La Salle, who
described the frozen stream as "like a plain paved with polished
marble," built and in the following summer launched the "Griffin,"
the first rude vessel that explored the Upper Lakes. Afterwards one
or two trading cabins appeared on Buffalo Creek, and then there was
constructed a stockade fort. For thirty years the hunters and traders
fought the savages and captured wild beasts, and then, after an
interval of peace, the War of 1812 came with new ravages, during
which the little settlement around the stockade at Buffalo was burnt
by the British, who held the fort at the entrance to Niagara River.
When the Erie Canal was opened, the expansion of the settlement
became rapid, and its eligible position at the point where the lake
commerce had to connect with the canal and the railways leading to
the Atlantic seaboard has since given full scope to business
enterprise and made it a large and wealthy city.
The Buffalo suburbs are gridironed by railroads, and their terminals
spread along the water-front and the sinuosities of Buffalo Creek.
The grain elevators, as in all the lake cities, are a prominent feature,
and they stand like huge monsters, forty of them, with high heads
and long trunks along the creek and canal basins as if waiting for
their prey. The fleets of vessels come over the lakes laden with grain
from the West; tugs take them to one of these monsters, and down
out of the long neck is plunged a trunk deep into the vessel's hold,
which sucks up all the grain. It is stored and weighed and sent on its
journey eastward. If this is by canal, the barge waits on the other
side, and the grain runs down into it through another trunk; if by
railway, the cars are run under or alongside the elevator and quickly
filled. Then the lake vessels are laden with coal for the return
voyage. While an American gives these elevators scant attention,
being used to them, not so the foreigner, who regards them with the
greatest curiosity. Thus wrote Anthony Trollope about them: "An
elevator is as ugly a monster as has yet been produced. In
uncouthness of form it outdoes those obsolete old brutes who used
to roam about the semi-aqueous world and live a most
uncomfortable life, with their great hungering stomachs and huge
unsatisfied maws. Rivers of corn and wheat run through these
monsters night and day. And all this wheat which passes through
Buffalo comes loose in bulk; nothing is known of sacks or bags. To
any spectator in Buffalo this becomes immediately a matter of
course; but this should be explained, as we in England are not
accustomed to see wheat travelling in this open, unguarded and
plebeian manner. Wheat with us is aristocratic, and travels always in
its private carriage."
The extensive commerce of Buffalo is varied by iron manufacturing,
breweries, distilleries, oil refineries and other industries, but the
elevators, coal chutes and railroad and canal business seem to
overshadow everything else. The city has wide tree-lined streets,
and is most handsome with its many fine buildings. There is an
extensive system of attractive parks connected by boulevards; broad
streets lined with well-built residences, and in the newer parts the
level surface is filled with ornamental homes, some most expensively
constructed and elaborately adorned. The well-kept lawns and
gardens are fully open to view, and Delaware Avenue, thus
bordered, is one of the most attractive streets. On the Main Street,
among many impressive structures, is the huge Ellicott Square
Building, said to be the largest office-building in the world, housing a
business community approximating five thousand persons. There are
also two public Libraries and many handsome churches.
The locality of greatest interest in Buffalo is probably the little
Prospect Park out at the edge of Lake Erie, where its waters flow
into Niagara River. The basins and harbor making the beginning of
the Erie Canal, which we have traced all across New York State, are
down at the edge of the lake, and a steep bluff, rising about sixty
feet, makes the verge of the Park, and continues around along the
bank of the river. Here it is crowned by an esplanade surrounding
the remains of old Fort Porter, a dilapidated relic of bygone days of
frontier conflicts. A couple of superannuated cannon point their
muzzles across the water towards Canada, but otherwise the locality
is peaceful. A small military force is kept here, probably to watch the
British Fort Erie over on the opposite river bank, a few hundred
yards off, but the worst conflicts now are bouts at playing ball. The
protecting harbor breakwater is out in front, and seen down the
Niagara River are the light trusses of the International Railway
Bridge, spanning its swift current, and the Erie Canal alongside the
bank. Into the narrow river sweeps the drainage of the Great Lakes,
an enormous mass of water, and in the centre the city has placed a
large crib, tapping the clear current for its water-supply. The
powerful torrent flows steadily northward out of Lake Erie, with a
speed of six or seven miles an hour, to make the Niagara cataract,
twenty miles away, and show its tremendous force in the Niagara
gorge. In the words of Goethe:

"Water its living strength first shows,


When obstacles its course oppose."

NIAGARA.
The Indians who first looked upon the world's greatest cataract gave
the best idea of it in their appropriate name, "The Thunder of
Waters." There is no setting provided for it in the charms of natural
scenery; it has no outside attractions. All its beauty and sublimity are
within the rocky walls of its stupendous chasm. The approaches
from every direction are dull and tedious, the surrounding country
being flat. The forests are sparse and there are few fine trees, these
being confined to the verge of the abyss, and being generally of
recent planting. The Niagara River flows northward from Lake Erie
through a plain. The Lake Erie level is five hundred and sixty-four
feet above the sea, and in its tortuous course of about thirty-six
miles to Lake Ontario, the Niagara River descends three hundred and
thirty-three feet, leaving the level of Ontario still two hundred and
thirty-one feet above the sea. More than half of all the fresh water
on the entire globe—the whole enormous volume from the vast lake
region of North America, draining a territory equalling the entire
continent of Europe, pours through this contracted channel out of
Lake Erie. There is a swift current for a couple of miles, but
afterwards the speed is gentler as the channel broadens, and Grand
Island divides it. Then it reunites into a wider stream, flowing
sluggishly westward, small islands dotting the surface. About fifteen
miles from Lake Erie the river narrows and the rapids begin. They
flow with great speed for a mile above the falls, in this distance
descending fifty-two feet, Goat Island dividing their channel at the
brink of the cataract, where the river makes a bend from the west
back to the north. This island separates the waters, although nine-
tenths go over the Canadian fall, which the abrupt bend curves into
horseshoe form. This fall is about one hundred and fifty-eight feet
high, the height of the smaller fall on the American side being one
hundred and sixty-four feet. The two cataracts spread out to forty-
seven hundred and fifty feet breadth, the steep wooded bank of
Goat Island, separating them, occupying about one-fourth the
distance. The American fall is about eleven hundred feet wide and
the Canadian fall twice that width, the actual line of the descending
waters on the latter being much larger than the breadth of the river
because of its curving form. Recent changes, caused by falling rock
in the apex of this fall, have, however, made it a more symmetrical
horseshoe than had been the case for years. The Niagara River, just
below the cataract, contracts to about one thousand feet, widening
to twelve hundred and fifty feet beneath the new single-arch steel
bridge recently constructed a short distance farther down. For seven
miles the gorge is carved out, the river banks on both sides rising to
the top level of the falls, and the bottom sinking deeper and deeper
as the lower rapids descend towards Lewiston, and in some places
contracting to very narrow limits. Two miles below the cataract the
river is compressed within eight hundred feet, and a mile farther
down, at the outlet of the Whirlpool, where a sharp right-angled turn
is made, the enormous current is contracted within a space of less
than two hundred and fifty feet. In the seven miles distance, these
lower rapids descend about one hundred and four feet, and then
with placid current the Niagara River flows a few miles farther
northward to Lake Ontario.
The view of Niagara is impressive alike upon sight and hearing, and
this impressiveness grows upon the visitor. From the bridge just
below the American fall, and from the Canadian side, the whole
grand scene is in full display, and quickly convinces that no
description can exaggerate Niagara. The Indians first told of the
falls, and they are indicated on Champlain's map of 1632. In 1648
the Jesuit missionary Rugueneau wrote of them as a "cataract of
frightful height." The first white man who saw them was Father
Louis Hennepin, the Franciscan, in 1678, who described them as "a
vast and prodigious cadence of water which falls down after a
surprising and astonishing manner, insomuch that the universe does
not afford its parallel. The waters which fall from this horrible
precipice do foam and boil after the most hideous manner
imaginable, making an outrageous noise more terrible than that of
thunder, for when the wind blows out of the south their dismal
roaring may be heard more than fifteen leagues off." Upon Charles
Dickens the first and enduring effect, instant and lasting, of the
tremendous spectacle, was: "Peace—peace of mind, tranquility, calm
recollections of the dead, great thoughts of eternal rest and
happiness." The falls had a sanative influence upon Professor
Tyndall, for, "quickened by the emotions there aroused," he says,
"the blood sped exultingly through the arteries, abolishing
introspection, clearing the heart of all bitterness, and enabling one
to think with tolerance, if not with tenderness, upon the most
relentless and unreasonable foe." After Anthony Trollope had looked
upon the cataract he wrote: "Of all the sights on this earth of ours, I
know no other one thing so beautiful, so glorious and so powerful.
That fall is more graceful than Giotto's Tower, more noble than the
Apollo. The peaks of the Alps are not so astounding in their solitude.
The valleys of the Blue Mountains in Jamaica are less green. The
finished glaze of life in Paris is less invariable; and the full tide of
trade around the Bank of England is not so inexorably powerful."

GEOLOGICAL FORMATION OF NIAGARA.


The estimate is that nine hundred millions of cubic feet of water
pour over Niagara every hour, and great as this mass is, there is a
belief that half the water passing into Lake Erie from the upper lakes
does not go over the falls, but finds its way into Ontario through a
subterranean channel. Nothing demonstrates this theory, but it is
advanced to account for the difference between the amount of water
accumulated in the upper lakes and that going over the falls. The
actual current is sufficiently enormous, however, and steadily
wearing away the rocks over which it descends, it has during the
past ages excavated the gorge of the lower rapids. The land surface,
which is low at Lake Erie, scarcely rising above the level of its
waters, gradually becomes more elevated towards the north, till near
Lewiston it is about forty feet above Erie. The Niagara River thus
flows in the direction of the ascent of this moderately inclined plane.
Beyond this the surface makes a sudden descent towards Lake
Ontario of about two hundred and fifty feet down to a plateau, upon
which stands Lewiston on the American side and Queenston on the
Canadian side of the river. There thus is formed a bold terrace
looking out upon Ontario, from which that lake is seven miles away,
and from the foot of the terrace the surface descends gently one
hundred and twenty feet farther to the lake shore. The gorge
through which the river flows is three hundred and sixty-six feet
deep at this terrace. There is no doubt the first location of the great
cataract was on the face of the terrace near Lewiston, and it has
gradually retired by the eating away, year after year, of the rocky
ledges over which the waters pour. This, however, has not been
done in a hurry, for the geologists studying the subject estimate that
it has required nearly thirty-seven thousand years to bring the falls
from Lewiston back to their present location. In fact, from the
stratification, Professor Agassiz expressed the opinion that at one
time there were three distinct cataracts in Niagara River.
During the brief time observations have been made, great fragments
of rocks have been repeatedly carried down by the current pouring
over Niagara, the frosts assisting disintegration. This caused not only
a recession but decided changes in appearance. Since 1842 the New
York State geologists, who then made a careful and accurate
topographical map, have been closely watching these changes, and
the average rate of recession is estimated at slightly over two feet
annually. In Father Hennepin's sketch of 1678 there was a striking
feature, since entirely disappeared, a third fall on the Canadian side
facing the line of the main cataract, and caused by a large rock
turning the diverted fall in this direction, this rock falling, however, in
the eighteenth century. The rate at which recessions occur is not
uniform. No change may be apparent for several years, and the soft
underlying strata being gradually worn away, great masses of the
upper and harder formations then tumble down, causing in a brief
period marked changes. At the present location of the cataract,
sheets of hard limestone cover the surface of the country, and from
the top of the falls to eighty or ninety feet depth. Shaly layers are
under these. All the strata slope gently downward against the river
current at the rate of about twenty-five feet to the mile. Above the
falls, in the rapids, the limestone strata are piled upon each other,
until about fifty feet more are added to the formation, when they all
disappear under the outcropping edges of the next series above,
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like