“91974˙CH01˙ﬁnal” — 2012/12/14 — 13:55 — page9—#9
1.5 Python Overview 9
Figure 1.2 The sum of the numbers 1 to N is
1.5 Python Overview
In this book the language you will use to write your computer programs is called Python.
Why did we choose Python instead of a language like C++ or Java? The answer is simple:
We want you to focus on learning the problem-solving strategies and techniques that a com-
puter scientist uses. Programming languages are tools and Python is a good beginning
tool. Languages like Java and C++ are ﬁne tools as well, but they require you to keep
track of many more details and they are harder to learn than Python.
The best way to learn Python is to try it out—so let’s get started. The ﬁrst thing we
are going to do is start the Python interpreter. Depending on your operating system,
there are any number of ways to do this. For example, you might start a program called
IDLE—named after Eric Idle of Monty Python fame. Or you might just type Python at
the command prompt. No matter how you start it, you will know you are successful when
you see a window such as the one shown in Figure 1.3. In this case, we have started the
Python interpreter from a terminal window on a MacBook Pro. For detailed instructions
on installing and starting Python on your system, refer to Appendix A.
As you progress through this chapter, you will see that example programs are in boxes
called listings, and commands that you can type interactively at the Python shell are in
boxes called sessions. Whenever you see a session box, we strongly encourage you to try
the session for yourself. Also, once you have typed in the example we have shown, feel free
to try some variations in order to ﬁnd out for yourself what works and what does not.