100% found this document useful (6 votes)
48 views

Get Programming and Mathematical Thinking A Gentle Introduction to Discrete Math Featuring Python 1st Edition Allan M. Stavely PDF ebook with Full Chapters Now

Python

Uploaded by

pagitzassem42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (6 votes)
48 views

Get Programming and Mathematical Thinking A Gentle Introduction to Discrete Math Featuring Python 1st Edition Allan M. Stavely PDF ebook with Full Chapters Now

Python

Uploaded by

pagitzassem42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

Download the full version of the ebook at ebookname.

com

Programming and Mathematical Thinking A Gentle


Introduction to Discrete Math Featuring Python 1st
Edition Allan M. Stavely

https://ebookname.com/product/programming-and-mathematical-
thinking-a-gentle-introduction-to-discrete-math-featuring-
python-1st-edition-allan-m-stavely/

OR CLICK BUTTON

DOWNLOAD EBOOK

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


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

Programming in Python 3 A Complete Introduction to the


Python Language 2nd Edition Summerfield

https://ebookname.com/product/programming-in-python-3-a-complete-
introduction-to-the-python-language-2nd-edition-summerfield/

ebookname.com

A Gentle Introduction to Optimization 1st Edition B.


Guenin

https://ebookname.com/product/a-gentle-introduction-to-
optimization-1st-edition-b-guenin/

ebookname.com

A Gentle Introduction to Stata 2018th Edition Alan C.


Acock

https://ebookname.com/product/a-gentle-introduction-to-stata-2018th-
edition-alan-c-acock/

ebookname.com

Experimental Approaches to Diabetic Retinopathy Frontiers


in Diabetes Vol 20 1st Edition H. P. Hammes

https://ebookname.com/product/experimental-approaches-to-diabetic-
retinopathy-frontiers-in-diabetes-vol-20-1st-edition-h-p-hammes/

ebookname.com
Building High Performance Business Relationships Rescue
Improve and Transform Your Most Valuable Assets 1st
Edition Tony Lendrum
https://ebookname.com/product/building-high-performance-business-
relationships-rescue-improve-and-transform-your-most-valuable-
assets-1st-edition-tony-lendrum/
ebookname.com

In Rivers Lakes and Ponds Under the Microscope 1st Edition


Sabrina Crewe

https://ebookname.com/product/in-rivers-lakes-and-ponds-under-the-
microscope-1st-edition-sabrina-crewe/

ebookname.com

Elements of set theory Enderton

https://ebookname.com/product/elements-of-set-theory-enderton/

ebookname.com

Nanomedicine Design of Particles Sensors Motors Implants


Robots and Devices Mark J. Schulz

https://ebookname.com/product/nanomedicine-design-of-particles-
sensors-motors-implants-robots-and-devices-mark-j-schulz/

ebookname.com

Israel Jordan and Palestine The Two State Imperative Asher


Susser

https://ebookname.com/product/israel-jordan-and-palestine-the-two-
state-imperative-asher-susser/

ebookname.com
The Phenomenon of Obama and the Agenda for Education Can
Hope Audaciously Trump Neoliberalism 1st Edition Paul R.
Carr
https://ebookname.com/product/the-phenomenon-of-obama-and-the-agenda-
for-education-can-hope-audaciously-trump-neoliberalism-1st-edition-
paul-r-carr/
ebookname.com
Programming and Mathematical
Thinking
A Gentle Introduction to Discrete Math
Featuring Python

Allan M. Stavely

The New Mexico Tech Press


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

Copyright © 2014 Allan M. Stavely

First Edition

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

Publisher's Cataloguing-in-Publication Data

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

QA 76.9 .M35 .S79 2014


004-dc22

OCLC Number: 863653804

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

The New Mexico Tech Press


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

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

iii
Programming and Mathematical Thinking

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


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

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

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

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


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

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


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

Many experienced programmers approach the design of a program by


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

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


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

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

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

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


mathematical structures might immediately think of a different approach:

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

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

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

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


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

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


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

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

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

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


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

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

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

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


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

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

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


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

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


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

• some types, such as complex and byte

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

• string formatting and many details of input and output

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

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


while-statements and for-statements

• many variations on function parameters and arguments, including default


values and keyword parameters

• exceptions and exception handling

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

• many variations on class definitions, including multiple inheritance and


decorators

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

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

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

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


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

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


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

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


result as in Python 3.

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

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

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

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

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

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

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

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

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


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

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

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

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

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


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

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

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

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

1
Programs, data, and mathematical objects

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


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

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

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

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


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

2
A first look at Python

1.2. A first look at Python


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

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

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

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


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

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

3
A first look at Python

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


throughout the book.

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

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

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

Example 1.1. Finding a name


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

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

4
A first look at Python

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

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

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

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

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

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

5
A first look at Python

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

John Atkins

Johnson Cummings

John Davis

John Hammerstein

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

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

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

6
A first look at Python

Example 1.2. Finding an email address


file = open("emails")
for line in file:
name, email = line.split(",")
if name == "John Davis":
print(email)

Let's look at this program a line or two at a time.


file = open("emails")
for line in file:

These lines are very much like the first two lines of the previous program; the
only difference is the name of the file in the first line. In fact, this pattern of
code is common in programs that read a file and do something with every line
of it.
name, email = line.split(",")

The part line.split(",") splits line into two pieces at the comma. The result
is two things: the piece before the comma and the piece after the comma. We
give the names “name” and “email” to those two things.
if name == "John Davis":

This says: if name equals (in other words, is the same as) “John Davis”, do
what comes next. Python uses “==”, two adjacent equals-signs, for this kind
of comparison. You might think that just a single equals-sign would mean
“equals”, but Python uses “=” to associate a name with a thing, as we have
seen. So, to avoid any possible ambiguity, Python uses a different symbol for
comparing two things for equality.
print(email)

This displays the result that we want.

As our final example, let's take a very simple computational task: finding the
average of a collection of numbers. They might be a scientist's measurements

7
A first look at Python

of flows in a stream, or the balances in a person's checking account on different


days, or the weights of different boxes of corn flakes. It doesn't matter what
they mean: for purposes of our computation, they are just numbers.

Let's say, for the sake of the example, that they are temperatures. You have
a thermometer outside your window, and you read it at the same time each
day for a month. You record each temperature to the nearest degree, so all
your observations are whole numbers (the mathematical term for these is
“integers”). You put the numbers into a file on your computer, perhaps using
a text-editing or word-processing program; let's say that the name of the file
is “observations”. At the end of the month, you want to calculate the average
temperature for the month.

Example 1.3 shows a Python program that will do that computation. It's a
little longer than the previous two programs, but it's still short and simple
enough that we might call it a “script”.

Example 1.3. Average of a collection of observations


sum = 0
count = 0

file = open("observations")
for line in file:
n = int(line)
sum += n
count += 1

print(sum/count)

Let's look at this program a line or two at a time.


sum = 0
count = 0

To compute the average of the numbers in the file, we need to find the sum
of all the numbers and also count how many there are. Here we give the names

8
A first look at Python

sum and count to those two values. We start both the sum and the count at
zero.
file = open("observations")
for line in file:

As in the previous two programs, these lines say: open the file that we want
and then, for each line of the file, do what comes next. Specifically, do the
lines that are indented, the next three lines.
n = int(line)

A line of a file is simply a sequence of characters. In this case, it will be a


sequence of digits. The program needs to convert that into a single thing, a
number. That's what int does: it converts the sequence of digits into an integer.
We give the name n to the result.
sum += n
count += 1

In Python, “+=” means “add the thing on the right to the thing on the left”.
So, “sum += n” means “add n to sum” and “count += 1” means “add 1 to
count”. This is the obvious way to accumulate the running sum and the running
count of the numbers that the program has seen so far.
print(sum/count)

This step is done after all the numbers in the file have been summed and
counted. It displays the result of the computation: the average of the numbers,
which is sum divided by count.

Notice, by the way, that we've used blank lines to divide the lines of the
program into logical groups. You can do this in Python, and programmers
often do. This doesn't affect what the program does, but it might make the
program a little easier for a person to read and understand.

So now you've seen three very short and simple Python programs. They aren't
entirely typical of Python programs, though, because they illustrate only a
few of the most basic parts of the Python language. Python has many more

9
A little mathematical terminology

features, and you'll learn about many of them in the remaining chapters of
this book. But these programs are enough examples of Python for now.

1.3. A little mathematical terminology


Now we'll introduce a few mathematical terms that we'll use throughout the
book. We won't actually be doing much mathematics, in the sense of deriving
formulas or proving theorems; but, in keeping with the theme of the book,
we'll constantly use mathematical terminology as a vocabulary for talking
about programs and the computational problems that we solve with them.

The first term is set. A set is just an unordered collection of different things.

For example, we can speak of the set of all the people in a room, or the set of
all the books that you have read this year, or the set of different items that
are for sale in a particular shop.

The next term is sequence. A sequence is simply an ordered collection of things.

For example, we can speak of the sequence of digits in your telephone number
or the sequence of letters in your surname. Unlike a set, a sequence doesn't
have the property that all the things in it are necessarily different. For example,
many telephone numbers contain some digit more than once.

You may have heard the word “set” used in a mathematical context, or you
may know the word just from its ordinary English usage. It may seem strange
to call the word “sequence” a mathematical term, but it turns out that

10
A little mathematical terminology

sequences have some mathematical properties that we'll want to be aware of.
For now, just notice the differences between the concepts “set” and “sequence”.

Let's try applying these mathematical concepts to the sample Python programs
that we've just seen. In each of them, what kind of mathematical object is the
data that the program operates on?

First, notice that each program operates on a file. A file, at least as a Python
program sees it, is a sequence of lines. Code like this is very common in Python
programs that read files a line at a time:
file = open("observations")
for line in file:

In general, the Python construct

for element in sequence :

is the Python way to do something with every element of a sequence, one


element at a time.

Furthermore, each line of a file is a sequence of characters, as we have already


observed. So we can describe a file as a sequence of sequences.

But let's look deeper.

Let's take the file of names in our first example (Example 1.1). In terms of the
information that we want to get from it, the file is a collection of names. What
kind of collection? We don't care about the order of names in it; we just want
to see all the names that start with “John”. So, assuming that our lecturer
hasn't included any name twice by mistake, the collection is a set as far as
we're concerned.

In fact, both the input and the output of this program are sets. The input is
the set of names of people who attended the lecture. The output is the set of
members of that input set that start with the letters “John”. In mathematical
terminology, the output set is a subset of the input set.

11
Random documents with unrelated
content Scribd suggests to you:
John Philip Sousa

John Philip Sousa, America’s foremost composer of march music,


was born in Washington, D. C., on November 6, 1854. The son of a
trombone player in the United States Marine Band, John Philip early
received music instruction, mainly the violin from John Esputa. When
he was about thirteen, John enlisted in the Marine Corps where he
played in its band for two years. For several years after that he
played the violin in and conducted the orchestras of various
theaters; in the summer of 1877 he played in an orchestra
conducted by Jacques Offenbach at the Philadelphia Centennial
Exposition. Between 1880 and 1892 he was the musical director of
the Marine Band. It was during this period that he wrote his first
famous marches. In 1892 he formed a band of his own with which
he toured Europe and America for many years, and with which he
gave more than a thousand concerts. His most popular marches
(together with his best transcriptions for band of national ballads
and patriotic airs) were always the highlights of his concerts. Besides
the marches, Sousa wrote the music for numerous comic operas, the
most famous being El Capitan (1896) and The Bride Elect (1898). In
1918 Sousa and his band were heard in the Hippodrome
extravaganza, Everything. He published his autobiography, Marching
Along, in 1928, and died in Reading, Pennsylvania, on March 6,
1932.

In the closing years of the 19th century, and in the first part of the
20th, America was undergoing expansion in many directions: art,
science, literature, commerce, finance, world affairs. Hand in hand
with this development and growth came an aroused patriotism and
an expanding chauvinism. Sousa’s marches were the voice of this
new and intense national consciousness.

As Sigmund Spaeth has pointed out, most of Sousa’s famous


marches follow a similar pattern, beginning with “an arresting
introduction, then using a light, skipping rhythm for his first melody,
going from that into a broader tune,” then progressing to the
principal march melody. A massive climax is finally realized with new,
vibrant colors being realized in the main march melody 284
through striking new combinations of instruments.

The following are some of Sousa’s most popular marches:

El Capitan (1896) was adapted from a choral passage from the


comic opera of the same name. This music was played aboard
Admiral Dewey’s flagship, Olympia, when it steamed down Manila
Bay for battle during the Spanish-American War. And it was again
heard, this time performed by Sousa’s own band, when Dewey was
welcomed as a conquering hero in New York on September 30,
1900.

King Cotton (1895) was written on the occasion of the engagement


of the Sousa Band at the Cotton States Exposition. Semper Fideles
(1888) was Sousa’s first famous composition in march tempo, and to
this day it is still one of his best known marches, a perennial favorite
with parades of all kinds. Since Sousa sold this march outright for
$35.00 he never capitalized on its immense popularity.

Sousa’s masterpiece—and probably one of the most famous marches


ever written—was the Stars and Stripes Forever, completed on April
26, 1897. In 1897 Sousa was a tourist in Italy when he heard the
news that his friend and manager had died in the United States.
Sousa decided to return home. Aboard the Teutonic a march melody
kept haunting him. As soon as he came home he put the melody
down on paper, and it became the principal subject of “The Stars
and Stripes Forever.” This principal melody achieves an unforgettable
climax in the march when it is proudly thundered by the full
orchestra to figurations in the piccolo.

The Thunderer and The Washington Post March were written in


1889. The latter was commissioned by the Washington Post for the
ceremonies attending the presentation of prizes in a student essay
contest.

Among Sousa’s other marches are The Bride Elect (1897) from the
comic opera of the same name; The Fairest of the Fair (1908);
Hands Across the Sea (1899); Invincible Eagle (1901); and Saber
and Spurs (1915) dedicated to the United States Cavalry.

It was long maintained that Sousa was the composer of the famous
hymn of the Artillery branch of the United States armed services,
“The Caisson Song.” Sousa played this march in his own brilliant new
band arrangement at a Liberty Loan Drive at the Hippodrome, in
New York, in 1918. For some time thereafter Sousa was credited as
being the composer. But further research revealed the fact that the
words and music had been written in 1908 by Edmund L. Gruber,
then a lieutenant with the 5th Artillery in the Philippines.

285
Oley Speaks

Oley Speaks was born in Canal Winchester, Ohio, on June 28, 1874.
He received his musical training, principally in voice, from various
teachers including Armour Galloway and Emma Thursby. He then
filled the post of baritone soloist at churches in Cleveland, Ohio, and
New York City, including the St. Thomas Church in New York from
1901 to 1906. He also filled numerous engagements in song recitals
and performances of oratorios. He died in New York City on August
27, 1948.

Speaks was the composer of more than 250 published art songs
which have placed him in a front rank among American song
composers. Three have become outstandingly popular; there is
hardly a male singer anywhere who has not sung such all-time
favorites as “Morning,” “On the Road to Mandalay” and “Sylvia,” each
of which is among the most widely circulated and most frequently
heard art songs by an American. “Morning,” words by Frank L.
Stanton, was published in 1910. Where “Morning” is lyrical, “On the
Road to Mandalay” (published in 1907) is dramatic, a setting of the
famous poem by Rudyard Kipling. The persistent rhythmic
background suggesting drum beats, and the effective key change
from verse to chorus, have an inescapable effect on listeners.
“Sylvia,” poem by Clinton Scollard, published in 1914, is in a
sentimental mood, and like “Morning” reveals the composer’s
marked gift for sensitive lyricism.

286
Robert Stolz

Robert Stolz was born in Graz, Austria, on August 25, 1882. His
parents were musical, his father being a successful conductor and
teacher, and his mother a concert pianist. Robert’s music study took
place first with his father, then with Robert Fuchs in Vienna and
Humperdinck in Berlin. In 1901 he assumed his first post as
conductor, at an opera house in Brunn. When he was twenty-five he
was appointed conductor of the Theater-an-der-Wien in Vienna
where he remained twelve years, directing most of the masterworks
in the field of Austrian and German operettas. His own career as
composer of operettas had begun in 1903 with Schoen Lorchen
produced in Salzburg. Since then Stolz has written music for about
sixty operettas, scores for more than eighty films, and a thousand
songs in all. His music is in the light, graceful, ebullient style that has
characterized Viennese operetta music since the time of Johann
Strauss II. His most famous operettas are: Die lustigen Weiber von
Wien (1909), Die Gluecksmaedel (1910), Die Tanzgraefin (1921),
Peppina (1931), Zwei Herzen in dreiviertel Takt (1933), Fruehling im
Prater (1949) and Karneval in Wien (1950). In 1938 Stolz came to
the United States where for several years he worked in Hollywood.
After the end of World War II he returned to Vienna, remaining
active as a composer not only in that city but also in Berlin and
London.

Stolz’ most famous song is “Im Prater bluehn wieder die Baeume”
(“In the Prater the Trees Are Again Blooming”), a glowing hymn not
only to a district in Vienna famous for its frolic and amusement but
even more so to the city of Vienna itself.
A waltz from his operetta, Two Hearts in Three-Quarter Time (Zwei
Herzen in dreiviertel Takt) is perhaps one of the most celebrated
pieces in three-quarter time written in Vienna since Lehár, and it is
loved the world over. This operetta originated in 1931 as a German
motion-picture which won accolades around the world for its charm
and freshness, for which Stolz wrote a score that included his
famous waltz. It was then adapted for the stage by Paul Knepler and
J. M. Willeminsky and introduced in Zurich, Switzerland, in 1933.
This delightful text concerns the trials and tribulations of producing
an operetta. That operetta is accepted for production on the 287
condition that a good waltz melody is written for it, and the
composer Toni Hofer gets his inspiration for that tune from lovely
Hedi, the young sister of the librettist. This waltz, of course, is the
title number, which, in its lilt and buoyancy and Viennese love of life,
is in the best tradition of Viennese popular music.
Oscar Straus

Oscar Straus was no relation to any of the famous Viennese


Strausses; nevertheless in the writing of light, gay music in waltz
tempo and spirited melodies for the operetta stage he was certainly
their spiritual brother. He was born in Vienna on March 6, 1870, and
studied music with private teachers in Vienna and Berlin, including
Max Bruch. In 1901 he settled in Berlin where he became conductor
at a famous cabaret, Ueberbrettl, for whose productions of farces he
wrote a number of scores. Soon after that he turned to writing
operettas, becoming world famous with The Waltz Dream in 1907
and The Chocolate Soldier in 1908, both introduced in Vienna. He
wrote about thirty operettas after that, many heard with outstanding
success in the music centers of the world. The best of these were
Der letzte Walzer (1920), Die Teresina (1921), Drei Walzer (1935),
and Bozena (1952). He was at his best writing waltz melodies but he
was also skilful in interpolating satirical elements into his musical
writing through the exploitation of ragtime, jazz, and the shimmy.
Straus lived in Berlin until 1927, and for a decade after that he made
his home in Vienna and Paris. In 1939 he became a French citizen,
and from 1940 to 1948 he lived in the United States, filling some
assignments in Hollywood. He returned to his native land in 1948,
and died at Bad Ischl, Austria, on January 11, 1954.

The Chocolate Soldier (Der tapfere Soldat) was the operetta


adaptation of Bernard Shaw’s comedy, Arms and the Man, by R.
Bernauer and L. Jacobsen. Its première took place in Vienna on
November 14, 1908, with the first American performance 288
taking place a year later at the Casino Theater in New York.
The setting is Serbia in 1885 where the hero, Lieutenant Bumerli,
gains the nickname of “chocolate soldier” because of a sweet tooth.
While escaping from the enemy, he finds refuge in the bedroom of
Nadina, daughter of Colonel Popoff. Nadina becomes the instrument
by means of which the lieutenant is now able to effect his escape,
disguised in the coat of Colonel Popolf. But before the final curtain
Bumerli and Nadina also become lovers.

The waltz, “My Hero,” (“Komm, Komm, Held meiner Traeume”)


Nadina’s waltz of love to the chocolate soldier, is the most celebrated
excerpt from this operetta. Other familiar pages include the lovely
first act duet of Nadina and Bumerli, “Sympathy”; the little orchestral
march in the second act, a satirical take off on military pomp and
circumstance; and Nadina’s “Letter Song” in the third act.

A Waltz Dream (Ein Walzertraum), book by Felix Doermann and


Leopold Jacobsen, was introduced in Vienna on March 2, 1907, and
in New York in April 1908. Lieutenant Niki of the Austrian army is
ordered by the Austrian Emperor to marry Princess Helen, but he
falls in love with Frantzi, a violinist in a girl’s orchestra. This love
affair becomes frustrated when Niki must return to Vienna to
become Prince Consort.

The main musical selection from this operetta is the title number, a
waltz which first appears as a duet between Niki and a fellow officer
in the first act, then recurs throughout the operetta, and finally
brings it to a close. Two sprightly march excerpts, from the second
and third acts respectively, and the duet, “Piccolo, piccolo, tsin, tsin,
tsin” are also popular.
Eduard Strauss

Eduard Strauss, the younger brother of Johann Strauss II, was born
in Vienna on March 15, 1835. He studied music in Vienna with G.
Preyer following which he made his café-house debut in 1862 289
by conducting his father’s orchestra at the Dianasaal. He
continued to lead his father’s orchestra at the Volksgarten and
Musikverein as well as at various leading café-houses in Vienna. He
also made many tours, including two of the United States in 1892
and 1901. In 1902 he dissolved the musical organization which his
father had founded three-quarters of a century earlier and which all
that time had dominated the musical life of Vienna. Besides
conducting this orchestra, he also substituted from time to time for
his famous brother, Johann Strauss II, and in 1870 he succeeded
him as conductor of the court balls. Eduard Strauss died in Vienna
on December 28, 1916.

Eduard wrote over three hundred popular instrumental compositions


in the style of his celebrated brother but without ever equalling his
remarkable creative freshness and originality. But there is a good
deal of pleasurable listening in Eduard’s waltzes and polkas. In the
former category belongs the Doctrinen (Faith) Waltzes, op. 79; in
the latter, the gay Bahn Frei (Fast Track) Polka, op. 45. In
collaboration with his two brothers, Johann and Josef, Eduard wrote
the Trifolienwalzer and the Schuetzenquadrille.
Johann Strauss I

Johann Strauss I was one of the two waltz kings of Vienna bearing
that name. The more famous one, the composer of “The Blue
Danube” was the son. But the father was also one of Vienna’s most
popular composers and café-house conductors. He was born in
Vienna on March 14, 1804, and as a boy he studied both the violin
and harmony. His love for music, combined with the decision of his
parents to make him a bookbinder, led him to run away from home.
When he was fifteen he joined Michael Pamer’s orchestra which
played at the Sperl café; another of its members was Josef Lanner,
soon also to become a major figure in Vienna’s musical life. As
Lanner’s star rose, so did Johann Strauss’. First Strauss 290
played in the Lanner Quartet at the Goldenen Rebbuhn and
other cafés; after that he was a member of the Lanner Orchestra
which appeared in Vienna’s leading cafés. When Lanner’s mounting
success made it necessary for him to create two orchestras, he
selected Johann Strauss to conduct one of them. Then, in 1826,
Johann Strauss formed an orchestra of his own which made its
debut at the Bock Café. For the next two decades he was the idol of
Vienna, Lanner’s only rival. By 1830 he had two hundred musicians
under him. His major successes as a café-house conductor came at
the Sperl and the Redoutensaal. But his fame spread far beyond
Vienna. In 1833 he toured all Austria, and in 1834 he appeared in
Berlin. After that he performed in all the major European capitals,
achieving formidable successes in London and Paris. Meanwhile, in
1833, he had become bandmaster of the first Vienna militia
regiment, one of the highest honors a performer of light music could
achieve in Austria. In 1845 he was appointed conductor of the
Viennese court balls. He died in Vienna on September 25, 1849.

Like Lanner, Strauss wrote a considerable amount of dance and café-


house music, over 250 compositions. His first composition was the
Taeuberlwalzer, named after the café Zwei Tauben where he was
then appearing. After that he wrote waltzes, galops, polkas,
quadrilles, cotillons, contredanses, and marches—which Vienna
came to love for their rhythmic vitality and appealing lyricism. People
in Vienna used to say that the waltzes of the first Johann Strauss
were made for dancing because their rhythmic pulse excited the
heart and made feet restless.

Not much of the father Strauss’ library of music has survived. The
exceptions are the following waltzes: Caecilien, Donaulieder, the
Kettenbruecken, and the Lorelei Rheinsklaenge. To the waltz, the
older Johann Strauss brought a symphonic dimension it had
heretofore not known, particularly in his spacious introductions of
which the thirty-bar prelude of the Lorelei Rheinsklaenge is an
outstanding example. He also carried over to the waltz a variety of
mood and feeling and a lightness of touch new for this peasant
dance. “This demon of the ancient Viennese folk spirit,” wrote
Richard Wagner after hearing Strauss perform one of his own
waltzes in Vienna, “trembled at the beginning of a new waltz like a
python preparing to spring, and it was more the ecstasy produced
by the music than the drinks among the enchanted audience that
stimulated that magical first violin to almost dangerous flights.”

Of his other music the most famous is the Radetzky March. Count
Radetzky was an Austrian military hero, victor over the 291
Italians in 1848-1849. In honor of his Italian triumphs and
suppression of the Italian nationalist movement, Strauss wrote the
spirited, sharply accented march in 1848 which almost at once
became the musical symbol of Hapsburg Vienna and Austrian
military power. The following programmatic interpretation of this
music by H. E. Jacob is of interest: “Drunk with triumph, the
Generalissimo’s battalions hurl themselves down into Lombardy.
They are close on the heels of the fleeing troops of King Albert, the
King of Sardinia. And then comes a new phase of the march to
accompany the victorious troops. A different sun shines down on
this, a memory of Vienna, a lingering trace of the feel of girls’ arms;
scraps of a dance song with a backward glance at three-quarter
time. But on they go, still forward. There are no more shots, there is
laughter. The trio follows. The ... superdominant ... hoisted as if it
were a flag.... Finally comes the return of the principal theme with
the laurels and gaiety of victory.”
Johann Strauss II

Johann Strauss II, son of the first Johann Strauss, was born in
Vienna on October 25, 1825. Though he showed an unmistakable
bent for music from his childhood on, he was forbidden by his father
to study music or to indulge in any musical activity whatsoever. The
young Johann Strauss, encouraged by his mother, was forced to
study the violin surreptitiously with a member of his father’s
orchestra. Only after the father had deserted his family, to set up
another home with his mistress, did young Johann begin to devote
himself completely and openly to music. After studying the violin
with Kohlmann and counterpoint with Joseph Drechsler, he made his
debut as a café-house conductor and composer at Dommayer’s
Casino in Hietzing, near Vienna, on October 15, 1844. The event was
widely publicized and dramatized in Vienna, since the son 292
was appearing as a rival to his father. For this momentous
debut, the son wrote the first of his waltzes—the Gunstwerber and
the Sinngedichte—which aroused immense enthusiasm. He had to
repeat the last-named waltz so many times that the people in the
café lost count. “Ah, these Viennese,” reported the editor of The
Wanderer. “A new waltz player, a piece of world history. Good night,
Lanner. Good evening, Father Strauss. Good morning, Son Strauss.”
The father had not attended this performance, but learned of his
son’s triumph from one of his cronies.

Thus a new waltz king had arisen in Vienna. His reign continued until
the end of the century. For fifty years Johann Strauss II stood alone
and unequalled as the musical idol of Vienna. His performances were
the talk of the town. His own music was on everyone’s lips. After the
death of father Strauss in 1849, he combined members of the older
man’s orchestra with his own, and toured all of Europe with the
augmented ensemble. From 1863 to 1870 he was conductor of the
Viennese balls, a post once held by his father. In 1872 he made
sensational appearances in Boston and New York. All the while he
was writing some of the most famous waltzes ever written, as well
as quadrilles and polkas and other dance pieces. And in 1871, with
the première in Vienna of Indigo he entered upon a new field, that
of the operetta, in which once again he was to become a dominating
figure. He was admired not merely by the masses but also by some
of the greatest musicians of his generation—Brahms, Wagner, Verdi,
Hans von Buelow, Offenbach, Goldmark, Gounod, all of whom
expressed their admiration for his music in no uncertain terms. In
1894, Vienna celebrated the 50th anniversary of his debut with a
week of festive performances; congratulations poured into Vienna
from all parts of the civilized world. He died five years after that—in
Vienna on June 3, 1899—and was buried near Schubert, Beethoven,
and Brahms.

It is perhaps singularly fitting that Johann Strauss should have died


in 1899. A century was coming to an end, and with it an entire
epoch. This is what one court official meant when he said that
“Emperor Francis Joseph reigned until the death of Johann Strauss.”
History, with its cold precision, may accurately record that the reign
of Francis Joseph actually terminated in 1916. But its heyday had
passed with the 19th century. The spirit of old Vienna, imperial
Vienna of the Hapsburgs, the Vienna that had been inspiration for
song and story, died with Johann Strauss. After 1900, Vienna was
only a shadow of its former self, and was made prostrate by World
War I.

If the epoch of “old Vienna” died with Johann Strauss, it was 293
also born with him. After 1825, the social and intellectual
climate in the imperial city changed perceptibly. The people, always
gay, now gave themselves up to frivolity. For this, political conditions
had been responsible. The autocratic rule of Francis I brought on
tyranny, repression, and an army of spies and informers. As a result,
the Viennese went in for diversions that were safe from a political
point of view: flirtation, gossip, dancing. They were partial to light
musical plays and novels. Thus, an attitude born out of expediency,
became, with the passing of time, an inextricable part of everyday
life in Vienna.

Of the many light-hearted pleasures in which the Viennese indulged


none was dearer to them than dancing. It has been recorded that
one out of every four in Vienna danced regularly. They danced the
polka, and the quadrille; but most of all they danced the waltz.

Johann Strauss II was the genius of the Viennese waltz. More than
anybody before him or since he lifted the popular dance to such
artistic importance that his greatest waltzes are often performed at
symphony concerts by the world’s greatest orchestras under the
foremost conductors. Inexhaustible was his invention; richly
inventive, his harmonic writing; subtle and varied his gift at
orchestration; fresh and personal his lyricism; aristocratic his
structure. To the noted 20th century German critic, Paul Bekker, the
Strauss waltz contained “more melodies than a symphony of
Beethoven, and the aggregate of Straussian melodies is surely
greater than the aggregate of Beethoven’s.”

Actually the waltz form used by Strauss is basically that of Lanner


and of Strauss’ own father. A slow symphonic introduction opens the
waltz. This is followed by a series of waltz melodies (usually five in
number). A symphonic coda serves both as a kind of summation and
as a conclusion. But here the similarity with the past ends. This form
received from the younger Strauss new dimension, new
amplification. His introductions are sometimes like tone poems. The
waltz melodies are incomparably rich in thought and feeling, varied
in mood and style. A new concept of thematic developments enters
waltz writing with Strauss. And his codas, as his introductions, are
symphonic creations built with consummate skill from previously
stated ideas, or fragments of these ideas. No wonder, then, that the
waltzes of Johann Strauss have been described as “symphonies for
dancing.”

The following are the most popular of the Johann Strauss waltzes:

Acceleration (Accelerationen), op. 234, as the title indicates, derives


its effect from the gradual acceleration in tempo in the main waltz
melody. Strauss had promised to write a waltz for a ball at 294
the Sofiensaal but failed to deliver his manuscript even at the
zero hour. Reminded of his promise, he sat down at a restaurant
table on the night of the ball and hurriedly wrote off the complete
Acceleration Waltz on the back of a menu card, and soon thereafter
conducted the première performance.

Artist’s Life (Kuenstlerleben), op. 316, opens in a tender mood. A


transition is provided by an alternation of soft and loud passages,
after which the first waltz melody erupts zestfully as a tonal
expression of the lighthearted gaiety of an artist’s life. A similar
mood is projected by the other waltz melodies.

The Blue Danube (An der schoenen blauen Donau), op. 314, is
perhaps the most famous waltz ever written, and one of the
greatest. It is now a familiar tale how Brahms, while autographing a
fan of Strauss’ wife, scribbled a few bars of this waltz and wrote
underneath, “alas, not by Brahms.” Strauss wrote The Blue Danube
at the request of John Herbeck, conductor of the Vienna Men’s
Singing Society; thus the original version of the waltz is for chorus
and orchestra, the text being a poem by Karl Beck in praise of
Vienna and the Danube. Strauss wrote this waltz in 1867, and it was
introduced on February 15 of the same year at the Dianasaal by
Strauss’ orchestra, supplemented by Herbeck’s singing society. The
audience was so enthusiastic that it stood on the seats and
thundered for numerous repetitions. In the Spring of 1867, Strauss
introduced his waltz to Paris at the International Exposition where it
was a sensation. A tremendous ovation also greeted it when Strauss
performed it for the first time in London, at Covent Garden in 1869.
When Johann Strauss made his American debut, in Boston in 1872,
he conducted The Blue Danube with an orchestra numbering a
thousand instruments and a chorus of a thousand voices! Copies of
the music were soon in demand in far-off cities of Asia and Australia.
The publisher, Spina, was so deluged by orders he had to have a
hundred new copper plates made from which to print over a million
copies.

It is not difficult to see why this waltz is so popular. It is an eloquent


voice of the “charm, elegance, vivacity, and sophistication” of 19th
century Vienna—so much so that it is second only to Haydn’s
Austrian National Anthem as the musical symbol of Austria.

Emperor Waltz (Kaiserwalz), op. 437, was written in 1888 to


celebrate the 40th anniversary of the reign of Franz Joseph I. This is
one of Strauss’ most beautiful waltzes. A slow introduction spanning
seventy-four bars that has delicacy and grace, and is of a stately
march-like character, is Viennese to its very marrow. A 295
suggestion of the main waltz tune then appears quickly but is
just as quickly dismissed by a loud return of the main introductory
subject. Trombones lead to a brief silence. After some preparation, a
waltz melody of rare majesty finally unfolds in the strings. If this
wonderful waltz melody can be said to represent the Emperor
himself then the delightful waltz tunes that follow—some of almost
peasant character—can be said to speak for the joy of the Austrian
people in honoring their beloved monarch. An elaborate coda then
comes as the crown to the whole composition.

Morning Journals (Morgenblaetter), op. 279, was written for a


Viennese press club, the Concordia. Offenbach had previously
written for that club a set of waltzes entitled “Evening Journals.”
Strauss decided to name his music Morning Journals. The Offenbach
composition is today remembered only because it provided the
stimulus for Strauss’ title. But Strauss’ music remains—the four
waltzes in his freshest and most infectious lyric vein, and its
introduction highlighted by a melody of folk song simplicity.
Roses from the South (Rosen aus dem Sueden), op. 388, is a
potpourri of the best waltz tunes (each a delight) from one of the
composer’s lesser operettas, Spitzentuch der Koenigen (The Queen’s
Lace Handkerchief). The “south” in the title refers to Spain, the
background of the operetta, but there is nothing Spanish to this
unmistakably Viennese music.

Tales from the Vienna Woods (G’schichten aus dem Wiener Wald),
op. 325—performed for the first time by the Strauss orchestra at the
Neue Welt café in 1868—is a bucolic picture of Nature’s beauty in
the forests skirting Vienna. The beauty of Nature is suggested in the
stately introduction with its open fifths and its serene melody for
cello followed by a flute cadenza. All the loveliness of the Vienna
woods is then represented by a waltz melody (originally scored for
zither, but now most often presented by strings), a loveliness that is
carried on with incomparable grace and charm by the ensuing waltz
tunes.

Vienna Blood (Wiener Blut), op. 354, like so many other Strauss
waltzes, is a hymn of praise to Strauss’ native cities; but where other
waltzes are light and carefree, this one is more often moody,
dreamy, and at times sensual. After the introduction come four waltz
melodies, the first full of fire and the last one touched with
sentimentality. The second and third waltz tunes are interesting for
their rhythmic vitality and marked syncopations.

Voices of Spring (Fruehlingstimmen), op. 410—dedicated to the


renowned Viennese pianist, Albert Gruenfeld—is (like the 296
Tales from the Vienna Woods) an exuberant picture of the
vernal season, the joy and thrill that the rebirth of Nature always
provides to the Viennese.

Wine, Woman and Song (Wein, Weib und Gesang), op. 333, opens
with an eloquent mood picture that is virtually an independent
composition, even though it offers suggestions of later melodies.
This is a spacious ninety-one bar introduction that serves as an
eloquent peroration to the four waltz melodies that follow—each
graceful, vivacious, and at times tender and contemplative. Richard
Wagner, upon hearing Anton Seidl conduct this music, was so moved
by it that at one point he seized the baton from Seidl’s hand and
conducted the rest of the piece himself.

Strauss wrote other dance music besides waltzes. He was equally


successful in bringing his wonderful melodic invention, fine rhythmic
sense, and beautiful instrumentation to the Polka, the native
Bohemian dance in duple quick time and in a lively mood. The best
of the Strauss polkas are: Annen-Polka, op. 117; Electrophor Polka,
op. 297 dedicated to the students of a Vienna technical school, its
effect derived from its breathless tempo and forceful dynamics;
Explosions Polka, op. 43, written when Strauss was only twenty-two
and characterized by sudden brief crescendos; Pizzicato Polka,
written in collaboration with the composer’s brother Josef, and, as
the name indicates, an exercise in plucked strings; and the
capricious Tritsch-Tratsch (or Chit-Chat) Polka, op. 214.

Of Strauss’ other instrumental compositions, the best known is a


lively excursion in velocity called Perpetual Motion, op. 257, which
the composer himself described as a “musical jest.”

Beyond being Vienna’s waltz king, Johann Strauss II was also one of
its greatest composers of operettas. Indeed, if a vote were to be
cast for the greatest favorite among all Vienna operettas the chances
are the choice would fall on Strauss’ Die Fledermaus (The Bat), first
produced in Vienna on April 5, 1874, book by Carl Haffner and
Richard Genée based on a French play by Meilhac and Halévy. This
work is not only a classic of the light theater, but even a staple in the
repertory of the world’s major opera houses. It is a piece of dramatic
intrigue filled with clever, bright and at times risqué humor, as well
as irony and gaiety. The plot, in line with operetta tradition, involves
a love intrigue: between Rosalinda, wife of Baron von Eisenstein,
and Alfred. The Baron is sought by the police for some slight
indiscretion, and when they come to the Baron’s home and find
Alfred there, they mistake him for the Baron and arrest him. 297
Upon discovering he is supposed to be in jail, the Baron
decides to take full advantage of his liberty by attending a masked
ball at Prince Orlovsky’s palace and making advances there to the
lovely women. But one of the masked women with whom he flirts is
his own wife. Eventually, the identity of both is uncovered, to the
embarrassment of the Baron, and this merry escapade ends when
the Baron is compelled to spend his time in jail.

The overture is a classic, recreating the effervescent mood that


prevails throughout the operetta. It is made up of some of the
principal melodies of the opera: Rosalinda’s lament, “So muss allein
ich bleiben” first heard in the woodwind; the chorus, “O je, o je, wie
ruhrt mich dies” in the strings; and most important of all, the main
waltz of the operetta and the climax of the second act, also in the
strings.

Other delightful episodes frequently presented in instrumental


versions include the lovely drinking song, “Trinke, Liebchen, trinke
schnell”; the laughing song of the maid, Adele, “Mein Herr Marquis”;
the blood-warming czardas of the “Hungarian countess” who is
actually Rosalinda in disguise, “Klaenge der Heimat”; the stirring
hymn to champagne, “Die Majistaet wird anerkannt”; and the
buoyant waltz, “Du und du.”

The Gypsy Baron (Die Ziguenerbaron) is almost as popular as Die


Fledermaus. This is an operetta with libretto by Ignaz Schnitzer,
introduced in Vienna on October 24, 1885. Sandór Barinkay returns
to his ancestral home after having left it as a child. He finds it
swarming with gypsies who have made it their home, and he falls in
love with one of them, Saffi.

The overture is made up of material from the concerted finales,


beginning with the entrance of the gypsies in the first finale;
continuing with Saffi’s celebrated gypsy air, “So elend und treu”; and
culminating with the celebrated waltz music of the second act, the
Schatz, or Treasure, waltzes.

Other familiar excerpts include Sandór’s exuberant aria with chorus


from the first act “Ja, das alles auf Ehr,” probably the most
celebrated vocal excerpt from the entire operetta; and the Entry
March (Einzugmarsch) from the third act—for chorus and orchestra
in the operetta, but often given by salon ensembles in an orchestral
version.

298
Josef Strauss

Josef Strauss, like Eduard, is a younger brother of Johann Strauss II,


and son of Johann Strauss I. He was born in Vienna on August 22,
1827. He was an extremely talented young man not only in music
but even as architect and inventor. Of more serious and sober
disposition than either of his two brothers, he long regarded café-
house music condescendingly, his musical preference being for the
classics. His famous brother, Johann Strauss II, needing someone to
help him direct his orchestra, finally prevailed on Josef to turn to
café-house music. Josef made his debut as café-house conductor
and composer simultaneously on July 23, 1853, his first waltz being
Die Ersten. After that he often substituted for brother Johann in
directing the latter’s orchestra in Vienna and on extended tours of
Europe and Russia. Josef died in Vienna on July 21, 1870.

Josef Strauss wrote almost three hundred dance compositions.


Though certainly less inspired than his brother, Johann, he was also
far more important than Eduard. Josef’s best waltzes have much of
the lyrical invention, and the harmonic and instrumental invention of
those by Johann Strauss II. Perhaps his greatest waltz is the
Dorfschwalben aus Oesterreich (Swallows from Austria), op. 164, a
nature portrait often interrupted by the chirping of birds. Here
Josef’s outpouring of the most sensitive lyricism and delicate moods
is hardly less wondrous than that of Johann Strauss II. H. E. Jacob
went so far as to say that “since Schubert’s death there has been no
such melody. It is in the realm of the Impromptus and Moments
Musicaux. It breathes the sweet blue from which the swallows
come.”
Another Josef Strauss classic in three-quarter time is
Sphaerenklaenge (Music of the Spheres), op. 285, equally
remarkable for its spontaneous flow of unforgettable waltz tunes.
Among Strauss’ other delightful waltzes are the Aquarellen, op. 258;
Delirien, op. 212; Dynamiden, op. 173; Marienklaenge, op. 214. A
theme from Dynamiden waltzes was used by Richard Strauss in his
famous opera Der Rosenkavalier.

In collaboration with his brother, Johann, Josef wrote the famous


Pizzicato Polka and several other pieces including the 299
Monstrequadrille and Vaterlandischer March. With Johann
and Eduard he wrote the Schuetzenquadrille and the Trifolienwalzer.
Sir Arthur Sullivan

Sir Arthur Seymour Sullivan—musical half of the comic-opera team


of Gilbert and Sullivan—was born in London, England, on May 13,
1842. The son of a bandmaster, Sullivan was appointed to the
Chapel Royal School in 1854. One year after that his first published
composition appeared, an anthem. In 1856 he was the first recipient
of the recently instituted Mendelssohn Award which entitled him to
attend the Royal Academy of Music where he studied under
Sterndale Bennett and Goss. From 1858 to 1861 he attended the
Leipzig Conservatory. After returning to London in 1862, he achieved
recognition as a serious composer with several ambitious
compositions including the Irish Symphony, a cello concerto, a
cantata, and an oratorio. Meanwhile, in 1866, he had become
professor of composition at the Royal Academy, and in 1867 he
completed his first score in a light style, the comic opera Cox and
Box, libretto by F. C. Burnand, which enjoyed a successful
engagement in London.

In 1871, a singer introduced Sullivan to W. S. Gilbert, a one-time


attorney who had attracted some interest in London as the writer of
burlesques. An enterprising impresario, John Hollingshead of the
Gaiety Theater, then was responsible for getting Gilbert and Sullivan
to work on their first operetta. This was Thespis, produced in
London in 1871, and a failure. It was several years before librettist
and composer worked together again. When they did it was for a
new impresario, Richard D’Oyly Carte, for whom they wrote a one-
act comic opera, Trial by Jury, a curtain raiser to a French operetta
which Carte was producing in London on March 25, 1875. Trial by
Jury—a stinging satire on court trials revolving around a breach of
promise suit—inaugurates the epoch of Gilbert and Sullivan. 300
D’Oyly Carte now commissioned Gilbert and Sullivan to create
a new full length comic opera for a company he had recently
formed. The new light opera company made a successful bow with
The Sorcerer, on November 17, 1877. Pinafore, a year later on May
25, 1878, made Gilbert and Sullivan a vogue and a passion both in
London and in New York. In 1879 Gilbert and Sullivan came to the
United States where on December 31 they introduced a new comic
opera, The Pirates of Penzance, that took the country by storm.
Upon returning to London, Gilbert and Sullivan opened a new
theater built for them by D’Oyly Carte—the Savoy—with Patience, a
tumultuous success on April 25, 1881. After that came Iolanthe
(1882), Princess Ida (1884), The Mikado (1885), the Yeomen of the
Guard (1888) and The Gondoliers (1889).

Gilbert and Sullivan came to the parting of the ways in 1890, the
final rift precipitated by a silly argument over the cost of a carpet for
the Savoy Theater. But the differences between them had long been
deep rooted. An attempt to revive the partnership was made in 1893
with Utopia Limited, and again with The Grand Duke in 1896. Both
comic operas were failures.

After 1893, Sullivan wrote a grand opera, Ivanhoe, and several


operetta scores to librettists other than Sullivan. None of these were
successful. During the last years of his life he suffered from
deterioration of his health, and was almost always in acute pain. He
died in London on November 22, 1900. Gilbert died eleven years
after that.

Of Sullivan’s other achievements in the field of music mention must


be made of his importance as a conductor of the concerts of the
London Philharmonic from 1885 to 1887, and of the Leeds Festival
from 1880 to 1898. Between 1876 and 1881 he was principal of, and
professor of composition at, the National Training School for Music.
In recognition of his high estate in English music, he was the
recipient of many honors. In 1878 he was made Chevalier of the
Legion of Honor, and in 1883 he was knighted by Queen Victoria.

It is irony fitting for a Gilbert and Sullivan comic opera that the music
on which Sullivan lavished his most fastidious attention and of which
he was most proud has been completely forgotten (except for one or
two minor exceptions). But the music upon which he looked with
such condescension and self apology is that which has made him an
immortal—in the theater if not in the concert world. For where
Sullivan was heavy-handed, pretentious, and often stilted in his
oratorios, serious operas, and orchestral compositions, he was
consistently vital, fresh, personal, and vivacious in his lighter 301
music. In setting Gilbert’s lyrics to music, Sullivan was always
capable of finding the musical mot juste to catch every nuance of
Gilbert’s wit and satire. So neatly, even inevitably, does the music fit
the words that it is often difficult to think of one without the other.
Like Gilbert, Sullivan was a master of parody and satire; he liked
particularly to mock at the pretensions of grand opera, oratorio, and
the sentimental ballad, pretensions of which he himself was a victim
when he endeavored to work in those fields. Like Gilbert, he had a
pen that raced with lightning velocity in the writing of patter music
to patter verses. Sullivan, moreover, had a reservoir of melodies
seemingly inexhaustible—gay tunes, mocking tunes, and tunes filled
with telling sentiment—and he was able to adapt the fullest
resources of his remarkable gift at harmony, rhythm and
orchestration to the manifold demands of the stage. He was no
man’s imitator. Without having recourse to experimentation or
unorthodox styles and techniques, his style and manners were so
uniquely his that, as T. F. Dunhill has said, “his art is always
recognizable.... The Sullivan touch is unmistakable and can be felt
instantly.”

Of the universality of the Gilbert and Sullivan comic operas, Isaac


Goldberg wrote: “They [Gilbert and Sullivan] were not the rebels of
an era, yet as surely they were not the apologists. Their light
laughter carried a pleasant danger of its own that, without being the
laughter of a Figaro, helped before the advent of a Shaw to keep the
atmosphere clear. Transition figures they were, in an age of
transition, caught between the personal independence of the artist
and the social imperatives of their station. They did not cross over
into the new day, though they served as a footbridge for others.
Darwin gave them ... only a song for Princess Ida, their melodious
answer to the revolt of woman against a perfumed slavery;
Swinburne and Wilde ... characters for Patience. They chided
personal foibles, and only indirectly social abuses. They were, after
all, moralists not sociologists. It was in their natures; it was of their
position. Yet something vital in them lives beyond their time. From
their era of caste, of smug rectitude, of sanctimoniousness, they still
speak to an age that knows neither corset nor petticoat, that votes
with its women, and finds Freud insufficiently aphrodisiac. Perhaps it
is because they chide individuals and not institutions that their work,
so admirably held in solution by Sullivan’s music, has lived through
the most critical epoch in modern history since the French
Revolution. For, underneath the cataclysmic changes of history
remain the foibles that make us the fit laughter of the gods.”

Overtures to and potpourris from the principal Gilbert and 302


Sullivan comic operas are integral to the repertory of salon
and pop orchestras everywhere. In all cases, the overture is made
up of the opera’s main melodies, and in most cases these overtures
were written by others.

The Gondoliers was the last of the Gilbert and Sullivan comic operas
to survive in the permanent repertory. It was produced on December
7, 1889. After the operatic pretension of the Yeomen of the Guard
which had preceded it, The Gondoliers represented a welcome
return by the authors to the world of paradox, absurdity, and
confusion. It has aptly been described as a “farce of errors.” The
setting is Venice in the middle of the 18th century. The Duke and
Duchess of Plaza-Toro come to Venice accompanied by their
daughter, Casilda, and a drummer boy, Luiz, who loves her. In her
childhood, Casilda had married the infant heir to the throne of
Barataria. This heir had then been stolen and entrusted to the care
of a gondolier who raised him as one of his two sons. In time the
gondolier himself has forgotten which of his two boys is of royal
blood. To complicate matters even further, the two gondolier boys,
Marco and Giuseppe, are married. Thus it seems impossible to solve
the problem as to who really is the heir to Barataria’s throne and by
the same token Gasilda’s husband. But when this problem is finally
unscrambled it turns out that the heir is neither Marco nor Giuseppe,
but none other than Luiz.

The following are the principal selections from The Gondoliers:


Antonio’s song, “For the Merriest Fellows Are We”; the duet of Marco
and Giuseppe, “We’re Called Gondolieri”; the autobiographical chant
of the Duke of Plaza-Toro, “The Duke of Plaza-Toro”; the duet of
Casilda and Luiz, “There Was a Time”; the song of the Grand
Inquisitor, “I Stole the Prince”; Tessa’s song, “When a Merry Maiden
Marries”; the duet of Marco and Giuseppe, “For Everyone Who Feels
Inclined”; Giuseppe’s patter song, “Rising Early in the Morning”;
Marco’s serenade, “Take a Pair of Sparkling Eyes”; and the song of
the Duchess, “On the Day that I was Wedded.”

Iolanthe, introduced on November 25, 1882, carried Gilbert’s love of


paradox, confusion and absurdity into the fairy kingdom. To Isaac
Goldberg, this comic opera, both as words and as music is “a peer
among its kind. It is surprisingly complete. It is, indeed, of Gilbert
and of Sullivan, all compact. The Gilbertian conflict between reality
and fantasy is mirrored in details great and small—in scene,
costume, in line, in gesture.... It would be difficult to find among the
remaining thirteen comic operas one that reveals the collaborators
playing so neatly into each other’s hands—responding so 303
closely to the conscious and unconscious demands of the
reciprocal personality.” The heroine, Iolanthe, is a fairy who has
married a mortal and thus has been banished to the bottom of a
stream by the Queen of her kingdom. But the Queen eventually
forgives Iolanthe. Upon returning to her fairy kingdom, Iolanthe
discovers she is the mother of a son, Strephon, who is half fairy and
half mortal; and Strephon is in love with the mortal, Phyllis, who, in
turn, is being pursued not only by her guardian, the Lord Chancellor,
but even by the entire House of Peers. When Phyllis finds Strephon
with Iolanthe she suspects him of infidelity, since she has no idea
that Iolanthe is Strephon’s mother. Immediately she begins to
bestow her kindly glances upon two members of the House of Peers.
Summoned for help, Iolanthe reveals that Strephon is, indeed, her
son, and that his father is none other than the Lord Chancellor. By
this time the other fairies of the kingdom have succumbed to the
charms and appeal of the Peers. Iolanthe is saved from a second
punishment when the Lord Chancellor helps change fairy law to read
that any fairy not marrying a mortal is subject to death.

Leading numbers from Iolanthe include the following: the opening


chorus of the fairies, “Tripping Hither, Tripping Thither”; Strephon’s
song, “Good Morrow, good Mother”; the love duet of Phyllis and
Strephon, “Thou the Tree and I the Flower”; Entrance, chorus, and
march of the Peers, “Loudly Let the Trumpet Bray” followed
immediately by the Lord Chancellor’s monologue, “The Law is the
True Embodiment”; the Lord Chancellor’s personal credo, “When I
Went to the Bar”; the song of Willis, the sentry, “When All Night
Long a Chap Remains”; Lord Mount Arrat’s chauvinistic hymn, “When
Britain Really Ruled the Waves”; the Fairy Queen’s song, “Oh, Foolish
Fay”; the Lord Chancellor’s patter song about a nightmare, “When
You’re Lying Awake”; the trio of the Lord Chancellor, Mount Ararat
and Tolloler, “If You Go In”; Strephon’s song, “Fold Your Flapping
Wings”; and the finale, “Soon as We May.”

The Mikado was a sensation when first performed in London on


March 14, 1885; and with many it is still the favorite of all Gilbert
and Sullivan comic operas. By 1900, it had received over one
thousand performances in London and five thousand in the United
States. Since then these figures have multiplied. It has been adapted
for motion pictures, and in New York it has been given in two
different jazz versions (The Hot Mikado and Swing Mikado). In 1960
it was presented over television with Groucho Marx as the Lord High
Executioner.

In its own day much of its appeal was due to its exotic 304
setting of Japan and strange Japanese characters. Such a
novelty for the English stage was the strong spice that endowed the
play with much of its succulent flavor. Gilbert’s inspiration had been
a miniature Japanese village set up in the Knightsbridge section of
London which aroused and stimulated the interest of the English
people in all things Japanese. Gilbert was one of those who became
fascinated by this Oriental exhibit, and his fascination led him to
conceive a comic opera with a Japanese background.

But while the Japanese are certainly no longer curiosities in the


theater—have, indeed, become a vogue on Broadway since the end
of World War II—The Mikado has never lost its tremendous
popularity. For The Mikado represents Gilbert and Sullivan at their
creative peak. The whimsical characters, absurd situations, the
savage malice of the wit and satire, and the strange and paradoxical
deviations of the plot find Gilbert at the height of his whimsical
imagination and skill; and at every turn, Sullivan was there with
music that captured every subtle echo of Gilbert’s fancy.

The thought of having to marry the unattractive Katisha proves so


distasteful to Nanki-Poo, son of the Mikado, that he puts on the
disguise of a wandering minstrel and flees. After coming to the town
of Titipu, he meets and falls in love with Yum-Yum who, in turn, is
being sought after by her own guardian, Ko-Ko, the Lord High
Executioner. The Lord High Executioner faces a major problem. The
ruler of Japan has sent a message to Titipu stating that since no
execution has taken place there for many years the office of Lord
High Executioner will be abolished if somebody is not executed
shortly. When Ko-Ko discovers that Nanki-Poo is about to commit
suicide, rather than live without Yum-Yum, he finds a solution to his
own problem. Ko-Ko is willing to allow Nanki-Poo to marry Yum-Yum
and live with her for a month if at the end of that time he allows

You might also like