small medium large xlarge

Practical Programming, Third Edition: An Introduction to Computer Science Using Python 3.6


Cover image for Practical Programming, Third Edition

Practical Programming, Third Edition

An Introduction to Computer Science Using Python 3.6


Classroom-tested by tens of thousands of students, this new edition of the best-selling intro to programming book is for anyone who wants to understand computer science. Learn about design, algorithms, testing, and debugging. Discover the fundamentals of programming with Python 3.6—a language that’s used in millions of devices. Write programs to solve real-world problems, and come away with everything you need to produce quality code. This edition has been updated to use the new language features in Python 3.6.

Customer Reviews

I wish I could go back in time and give this book to my 10-year-old self when I
first learned programming! It’s so much more engaging, practical, and accessible
than the dry introductory programming books that I tried (and often failed) to
comprehend as a kid. I love the authors’ hands-on approach of mixing explanations
with code snippets that students can type into the Python prompt.

- Philip Guo

Creator of Online Python Tutor, Asst. Professor, Dept. of Cognitive Science, UCSD

Practical Programming delivers just what it promises: a clear, readable, usable
introduction to programming for beginners. This isn’t just a guide to hacking
together programs. The book provides foundations to lifelong programming skills:
a crisp, consistent, and visual model of memory and execution and a design recipe
that will help readers produce quality software.

- Steven Wolfman

Professor of Teaching, Department of Computer Science, University of British Columbia

This excellent text reflects the authors’ many years of experience teaching Python
to beginning students. Topics are presented so that each leads naturally to the
next, and common novice errors and misconceptions are explicitly addressed.
The exercises at the end of each chapter invite interested students to explore
computer science and programming language topics.

- Kathleen Freeman

Director of Undergraduate Studies, Department of Computer and Information Science, University of Oregon

See All Reviews

Choose Your Format(s)

  • $26.95 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

What You Need

You’ll need to download Python 3.6, available from
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.6 and IDLE separately.)

Contents & Extracts

  • Acknowledgments
  • Preface
    • Our Approach
    • Further Reading
    • What You’ll See
    • Online Resources
  • What’s Programming?
    • Programs and Programming
    • What’s a Programming Language?
    • What’s a Bug?
    • The Difference Between Brackets, Braces, and Parentheses
    • Installing Python
  • Hello, Python excerpt
    • How Does a Computer Run a Python Program?
    • Expressions and Values: Arithmetic in Python
    • What Is a Type?
    • Variables and Computer Memory: Remembering Values
    • How Python Tells You Something Went Wrong
    • A Single Statement That Spans Multiple Lines
    • Describing Code
    • Making Code Readable
    • The Object of This Chapter
    • Exercises
  • Designing and Using Functions
    • Functions That Python Provides
    • Memory Addresses: How Python Keeps Track of Values
    • Defining Our Own Functions
    • Using Local Variables for Temporary Storage
    • Tracing Function Calls in the Memory Model
    • Designing New Functions: A Recipe
    • Writing and Running a Program
    • Omitting a return Statement: None
    • Dealing with Situations That Your Code Doesn’t Handle
    • What Did You Call That?
    • Exercises
  • Working with Text excerpt
    • Creating Strings of Characters
    • Using Special Characters in Strings
    • Creating a Multiline String
    • Printing Information
    • Getting Information from the Keyboard
    • Quotes About Strings
    • Exercises
  • Making Choices
    • A Boolean Type
    • Choosing Which Statements to Execute
    • Nested if Statements
    • Remembering Results of a Boolean Expression Evaluation
    • You Learned About Booleans: True or False?
    • Exercises
  • A Modular Approach to Program Organization
    • Importing Modules
    • Defining Your Own Modules
    • Testing Your Code Semiautomatically
    • Tips for Grouping Your Functions
    • Organizing Our Thoughts
    • Exercises
  • Using Methods
    • Modules, Classes, and Methods
    • Calling Methods the Object-Oriented Way
    • Exploring String Methods
    • What Are Those Underscores?
    • A Methodical Review
    • Exercises
  • Storing Collections of Data Using Lists
    • Storing and Accessing Data in Lists
    • Type Annotations for Lists
    • Modifying Lists
    • Operations on Lists
    • Slicing Lists
    • Aliasing: What’s in a Name?
    • List Methods
    • Working with a List of Lists
    • A Summary List
    • Exercises
  • Repeating Code Using Loops
    • Processing Items in a List
    • Processing Characters in Strings
    • Looping Over a Range of Numbers
    • Processing Lists Using Indices
    • Nesting Loops in Loops
    • Looping Until a Condition Is Reached
    • Repetition Based on User Input
    • Controlling Loops Using break and continue
    • Repeating What You’ve Learned
    • Exercises
  • Reading and Writing Files
    • What Kinds of Files Are There?
    • Opening a File
    • Techniques for Reading Files
    • Files over the Internet
    • Writing Files
    • Writing Example Calls Using StringIO
    • Writing Algorithms That Use the File-Reading Techniques
    • Multiline Records
    • Looking Ahead
    • Notes to File Away
    • Exercises
  • Storing Data Using Other Collection Types
    • Storing Data Using Sets
    • Storing Data Using Tuples
    • Storing Data Using Dictionaries
    • Inverting a Dictionary
    • Using the in Operator on Tuples, Sets, and Dictionaries
    • Comparing Collections
    • Creating New Type Annotations
    • A Collection of New Information
    • Exercises
  • Designing Algorithms
    • Searching for the Two Smallest Values
    • Timing the Functions
    • At a Minimum, You Saw This
    • Exercises
  • Searching and Sorting excerpt
    • Searching a List
    • Binary Search
    • Sorting
    • More Efficient Sorting Algorithms
    • Merge Sort: A Faster Sorting Algorithm
    • Sorting Out What You Learned
    • Exercises
  • Object-Oriented Programming
    • Understanding a Problem Domain
    • Function isinstance, Class object, and Class Book
    • Writing a Method in Class Book
    • Plugging into Python Syntax: More Special Methods
    • A Little Bit of OO Theory
    • A Case Study: Molecules, Atoms, and PDB Files
    • Classifying What You’ve Learned
    • Exercises
  • Testing and Debugging
    • Why Do You Need to Test?
    • Case Study: Testing above_freezing
    • Case Study: Testing running_sum
    • Choosing Test Cases
    • Hunting Bugs
    • Bugs We’ve Put in Your Ear
    • Exercises
  • Creating Graphical User Interfaces
    • Using Module tkinter
    • Building a Basic GUI
    • Models, Views, and Controllers, Oh My!
    • Customizing the Visual Style
    • Introducing a Few More Widgets
    • Object-Oriented GUIs
    • Keeping the Concepts from Being a GUI Mess
    • Exercises
  • Databases
    • Overview
    • Creating and Populating
    • Retrieving Data
    • Updating and Deleting
    • Using NULL for Missing Data
    • Using Joins to Combine Tables
    • Keys and Constraints
    • Advanced Features
    • Some Data Based On What You Learned
    • Exercises


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, has co-authored two textbooks, has been a leader in departmental curriculum design and renewal, and with Jennifer Campbell, got to teach Python to tens of thousands of students in a MOOC.

Jennifer Campbell is a teaching stream professor in Computer Science at the University of Toronto. In 2014, she received the Faculty of Arts and Science Outstanding Teaching Award. Jen engages in computer science education research, studying student experiences, factors for success, and the effectiveness of various course formats, including flipped and online courses.

Jason Montojo is a veteran software developer with 19 years of professional experience. He specializes in applied software archaeology and has mentored dozens of students as part of the Google Summer of Code and Software Carpentry programs.