Pages: 400
Published: September 2013
ISBN: 9781937785451
Edition: 2
In Print
This book is for anyone who wants to understand computer programming. You’ll learn to program in a language that’s used in millions of smartphones, tablets, and PCs. You’ll code along with the book, writing programs to solve real-world problems as you learn the fundamentals of programming using Python 3. You’ll learn about design, algorithms, testing, and debugging, and come away with all the tools you need to produce quality code. In this second edition, we’ve updated almost all the material, incorporating the lessons we’ve learned over the past five years of teaching Python to people new to programming.
Practical Programming, Third Edition, which covers Python 3.6, is now available!
Exercise Solutions: See Below
PDF for desktop/tablets
epub for Apple Books, e-readers
mobi for Kindle readers
Get all eBook formats here for $25.00 (USD)
Order via Bookshop (U.S. Only)
Please support indie bookstores!
Find a U.S. bookstore. Find an EU bookstore.
Exercise Solutions:
Chapter
2;
Chapter
3;
Chapter
4;
Chapter
5;
Chapter
6;
Chapter
7;
Chapter
8;
Chapter
9;
Chapter
10;
Chapter
11;
Chapter
12;
Chapter
13;
Chapter
14;
Chapter
15;
Chapter
16;
Chapter
17;
You don’t need any programming experience to get started. First, you’ll get a detailed introduction to Python and to programming. You’ll find out exactly what happens when your programs are executed. Through real-world examples, you’ll learn how to work with numbers, text, big data sets, and files. Then you’ll see how to create and use your own data types.
The incremental examples show you the steps and missteps that happen while developing programs, so you know what to expect when you tackle a problem on your own. Inspired by “How to Design Programs” (HtDP), you’ll learn a six-step recipe for designing functions, which helps you as you start to learn the concepts—and becomes an integral part of writing programs by the end.
As you learn to use the fundamental programming tools in the first half of the book, you’ll see how to document and organize your code so that you and other programmers can more easily read and understand it. Beyond the basics, you’ll learn how to ensure that your programs are reliable, and how to work with databases, download data from the web automatically, and build user interfaces. Most importantly, you’ll learn how to think like a professional programmer.
Exercises.
You’ll need to download Python 3, available from
python.org.
With that download comes IDLE, the editor we use for writing and
running Python programs. (If you use Linux, you may need to install
Python 3 and IDLE separately.)
Here are the details:
Practical Programming uses Python 3. As of July 2013, the most recent version is Python 3.3.2, although anything starting with a "3" will do. Python 2 is not compatible with the book.
The program we'll use to write Python programs is called
IDLE
.
Select the appropriate set of installation instructions:
Depending on the version of Linux you have, you might already have
Python 3 installed. To check, look for an application that gives you a
command line, such as Terminal
or xterm
, and
type python3
. You should see something like this:
pgries\@minty\$ python3\ Python 3.2.3 (default, Apr 10 2013, 05:07:54)\ \[GCC 4.7.2\] on linux2\ Type "help", "copyright", "credits" or "license" for more information.\ \>\>\>
To quit this, type Control-D.
Again, the exact version number doesn't matter, as long as it starts
with a 3
.
If you don't have Python 3 installed, you will see something like this:
pgries\@minty\$ python3\ python3: command not found
If you don't have Python 3 installed, you can use your package manager to install it, or you can install it from the command line. You might need to install IDLE separately; we have included instructions for that just in case:
Debian/Mint/Ubuntu:
pgries\@minty\$ sudo apt-get install python3\ pgries\@minty\$ sudo apt-get install idle3
Fedora/Red Hat/CentOS:
pgries\@minty\$ sudo yum install python3\ pgries\@minty\$ sudo yum install idle3
To test your installation, type idle3
at the command line.
You should see something like this window:
This is called the Python Shell, and is where we start in the book.
Follow these instructions to install Python 3 on Mac OS X.
Visit http://www.python.org/download/ and download the newest version of Python 3. You have two choices: the 64-bit/32-bit Installer and the 32-bit Installer. If you have a 64-bit system, choose the X86-64 MSI Installer; otherwise, choose the X86 MSI Installer. (If you are running OS X 10.5, you must choose the 32-bit installer.)
Open the downloaded disk image (.dmg
) and double-click
Python.mpkg
. Follow the instructions.
Visit http://www.activestate.com/activetcl/downloads and download and install the latest version of ActiveTcl.
To test your installation, open your Applications
folder,
find the Python 3.3
folder, and double-click
IDLE.app
. You should see something like this window:
This is called the Python Shell, and is where we start in the book.
Follow these instructions to install Python 3 on Microsoft Windows.
Visit http://www.python.org/download/ and download the newest version of Python 3. You have two choices: the X86 MSI Installer and the X86-64 MSI Installer. If you know you have a 64-bit system, choose the X86-64 MSI Installer; otherwise, choose the X86 MSI Installer.
Double-click the downloaded .msi
file and follow the
instructions. All the default options should be fine.
To test your installation, find Python 3 in your Start menu, click it,
and then click IDLE
. You should see something like this
window:
This is called the Python Shell, and is where we start in the book.
Releases:
Paul Gries has been teaching in the Department of Computer Science at the University of Toronto for more than 15 years. During his time at UofT, Paul has won numerous teaching awards, including UofT’s most prestigious teaching award and an Ontario-wide teaching award. Paul has also co-authored two textbooks, has been a leader in departmental curriculum design and renewal, and, with Jen, got to teach Python to tens of thousands of students in a MOOC.
Jennifer Campbell is a senior lecturer in the Department of Computer Science at the University of Toronto. Over the past 10 years, Jen’s primary focus has been on teaching and curriculum design of introductory courses. Jen is involved in several projects exploring student experiences in introductory computer science courses and the factors that contribute to success, including the effectiveness of the inverted classroom.
Jason Montojo is a research officer at the Donnelly Centre for Cellular and Biomolecular Research at the University of Toronto, where he develops scientific software for the Cytoscape and GeneMANIA projects. He has a strong interest in teaching computer science and frequently mentors students for Google’s Summer of Code program.
PDF for desktop/tablets
epub for Apple Books, e-readers
mobi for Kindle readers
Get all eBook formats here for $25.00 (USD)
Order via Bookshop (U.S. Only)
Please support indie bookstores!
Find a U.S. bookstore. Find an EU bookstore.
Pages: 400
Published: September 2013
ISBN: 9781937785451
Edition: 2
In Print