“46029˙PREF˙Miller” — 2008/8/14 — 11:23 — page v — #1
We (the authors, David and Brad) like to ski and we are pretty good at it, too. But that
level of competence only comes with practice, lots and lots of practice. The designers of ski
runs help with that practice by coding runs based on ability level. Green is for beginner,
blue is for intermediate, and black runs are for advanced skiers. However, this does not
suggest that green runs are void of the important skills that skiers need to become better.
Beginning runs still require turns, speed control, and the ability to start and stop.
One of the most unsettling things that we observe on the mountain occurs when a beginning
skier ventures out on the blue or black runs before they are ready. It can be an extremely
frustrating experience watching them as they slowly attempt to pick their way down the
hill, often falling, sometimes crying. The bottom line is that if you start out on the black
runs, you are likely to get frustrated and give up. You will often fail before you have the
chance to succeed.
Computer science deals with people who have problems to solve, and with algorithms, they
can ﬁnd the solutions to these problems. Computer science was never intended to be the
study of programming. To be a computer scientist means ﬁrst and foremost that you are
a problem solver, capable of constructing algorithms either from scratch or by applying
patterns from past experience.
Learning computer science is not unlike learning to ski in that the only way to be successful
is through deliberate and incremental exposure to the fundamental ideas of the discipline. A
beginning computer scientist needs practice in order to establish a thorough understanding
“46029˙PREF˙Miller” — 2008/8/14 — 11:23 — page vi — #2
of a concept before continuing on to the more complex parts of the curriculum. In addition,
a beginner needs the opportunity to be successful and gain conﬁdence.
As students progress through the introductory computer science sequence, we want them to
focus on aspects of problem solving, algorithm development, and algorithm understanding.
Unfortunately, many modern programming languages require that students jump into more
advanced programming concepts too early in their development. This practice sets them
up for possible failure, not because of the computer science, but because of the language
vehicle being used.
This book is designed to be a ﬁrst course in computer science that focuses on problem
solving, rather than language features. Therefore, we have structured the book around
problems of general interest, rather than a traditional language element structure. You will
not see chapter titles in this book like “loops” and “conditionals.” You will see chapter
titles like “Astronomy” and “Bears, Fish, and Plants, Oh My!” The content is still there,
but structured a little diﬀerently.
We use Python as the programming language because it has a clean, simple syntax and
an intuitive user environment. The basic collections are very powerful and yet easy to use.
The interactive nature of the language creates an obvious place to test ideas without the
need for a lot of coding. Finally, Python provides a textbook–like notation for representing
algorithms, alleviating the need for an additional layer of pseudocode. This allows the
illustration of many relevant, modern, and interesting problems that make use of algorithms.
Throughout the book, concepts are introduced using a spiral model. Because the syntax
of Python is so easy to learn we can introduce all of the standard programming constructs
very quickly. As students progress through the book, more of the details and background for
these constructs are introduced. Thus, students are exposed to important computer science
concepts when the concepts are needed to solve a problem.
An illustration of how this spiral approach touches on a speciﬁc topic in diﬀerent ways can
be seen in our presentation of functions. Students begin to write functions with parameters
in Chapter 1. Chapter 2 introduces functions with return values. In Chapter 6, students
learn about passing functions as parameters to other functions, and the details of Python’s
scoping rules. In Chapter 8, students learn about Python’s keyword and optional param-
eters. Chapter 9 covers recursive functions. In Chapter 10, students learn about writing
functions that are methods of a class.