Building Python Programs, 1st edition

  • Stuart Reges, 
  • Marty Stepp, 
  • Allison Obourn

Choose the option that's right for you


$9.99 / mo

4-month minimum term for $39.96

  • Access this eText title
  • Up to 2 devices
  • Discounted tutor access


$14.99 / mo

4-month minimum term for $59.96

  • Access over 1,500 titles
  • Up to 2 devices
  • Discounted tutor access

Learn more, spend less

  • Learn anytime, anywhere

    Get the app to access your eText whenever you need it

  • Make it your own

    Your notes. Your highlights. Your eText

  • Find it fast

    Quickly navigate your eText with search

  • Stay organized

    Access all your eTexts in one place

  • Easily continue access

    Keep learning with auto-renew


Building Python Programs takes a layered, back-to-basics approach to Python programming. After learning fundamentals, you'll explore new syntax and concepts over multiple chapters, including object-oriented programming. The text also focuses on problem solving with an emphasis on algorithmic thinking.

Published by Pearson (July 14th 2021) - Copyright © 2019

ISBN-13: 9780137530731

Subject: Pre-Programming & Introduction to Programming

Category: Python

Table of contents

Chapter 1 Introduction to Python Programming  

1.1 Basic Computing Concepts 

Why Programming?

Hardware and Software

The Digital Realm

The Process of Programming

Why Python?

The Python Programming Environment

1.2  And Now: Python  

Printing Output

String Literals (Strings)

Escape Sequences

Printing a Complex Figure

Comments, Whitespace, and Readability

1.3 Program Errors

Syntax Errors

Logic Errors (Bugs)

1.4  Procedural Decomposition


Flow of Control

Identifiers and Keywords

Functions That Call Other Functions

An Example Runtime Error

1.5 Case Study: Drawing Figures

Structured Version

Final Version without Redundancy

Analysis of Flow of Execution

Chapter 2 Data and Definite Loops 

2.1 Basic Data Concepts




Arithmetic Operators  


Mixing and Converting Types

2.2 Variables 

A Program with Variables

Increment/Decrement Operators  

Printing Multiple Values

2.3 The for Loop  

Using a Loop Variable 

Details about Ranges

String Multiplication and Printing Partial Lines

Nested for Loops

2.4 Managing Complexity  




2.5 Case Study: Hourglass Figure

Problem Decomposition and Pseudocode 

Initial Structured Version

Adding a Constant

Chapter 3 Parameters and Graphics

3.1 Parameters

The Mechanics of Parameters 

Limitations of Parameters

Multiple Parameters

Parameters versus Constants

Optional Parameters 

3.2  Returning Values 

The math Module

The random Module 

Defining Functions That Return Values

Returning Multiple Values    

3.3 Interactive Programs

Sample Interactive Program

3.4 Graphics   

Introduction to DrawingPanel 

Drawing Lines and Shapes


Drawing with Loops

Text and Fonts


Procedural Decomposition with Graphics 

3.5 Case Study: Projectile Trajectory 

Unstructured Solution

Structured Solution

Graphical Version

Chapter 4 Conditional Execution

4.1 if/else Statements

Relational Operators

Nested if/else Statements

Factoring if/else Statements 

Testing Multiple Conditions

4.2 Cumulative Algorithms

Cumulative Sum

Min/Max Loops

Cumulative Sum with if

Roundoff Errors

4.3 Functions with Conditional Execution

Preconditions and Postconditions

Raising Exceptions

Revisiting Return Values

Reasoning about Paths

4.4 Strings

String Methods

Accessing Characters by Index

Converting between Letters and Numbers

Cumulative Text Algorithms

4.5 Case Study: Basal Metabolic Rate

One-Person Unstructured Solution

Two-Person Unstructured Solution

Two-Person Structured Solution

Procedural Design Heuristics

Chapter 5 Program Logic and Indefinite Loops

5.1 The while Loop 

A Loop to Find the Smallest Divisor

Loop Priming

5.2 Fencepost Algorithms   

Fencepost with if   

Sentinel Loops     

Sentinel with Min/Max      

5.3 Boolean Logic 

Logical Operators  

Boolean Variables and Flags 

Predicate Functions 

Boolean Zen  

Short-Circuited Evaluation   

5.4 Robust Programs  

The try/except Statement  

Handling User Errors         

5.5 Assertions and Program Logic

Reasoning about Assertions  

A Detailed Assertions Example 

5.6  Case Study: Number Guessing Game  

Initial Version without Hinting

Randomized Version with Hinting

Final Robust Version

Chapter 6 File Processing

6.1  File-Reading Basics   

Data and Files       

Reading a File in Python 

Line-Based File Processing  

Structure of Files and Consuming Input

Prompting for a File

6.2 Token-Based Processing 

Numeric Input  

Handling Invalid Input 

Mixing Lines and Tokens

Handling Varying Numbers of Tokens     

Complex Input Files   

6.3  Advanced File Processing 

Multi-Line Input Records   

File Output      

Reading Data from the Web

6.4 Case Study: ZIP Code Lookup

Chapter 7 Lists

7.1 List Basics 

Creating Lists     

Accessing List Elements   

Traversing a List   

A Complete List Program   

Random Access   

List Methods

7.2 List-Traversal Algorithms  

Lists as Parameters                     

Searching a List 

Replacing and Removing Values

Reversing a List                                                                                         

Shifting Values in a List                                                                            

Nested Loop Algorithms                                                                         

List Comprehensions                                                                                

7.3 Reference Semantics                                                                         

Values and References                                                                            

Modifying a List Parameter                                                                    

The Value None                                                                                        



7.4 Multidimensional Lists                                                                      

Rectangular Lists                                                                                      

Jagged Lists                                                                                   

Lists of Pixels                                                                                  

7.5 Case Study: Benford's Law                                                               

Tallying Values

Completing the Program

Chapter 8 Dictionaries and Sets

8.1 Dictionary Basics                                                                                

Creating a Dictionary                                                                               

Dictionary Operations                                                                             

Looping Over a Dictionary                                                                      

Dictionary Ordering                                                                                 

8.2 Advanced Dictionary Usage                                                             

Dictionary for Tallying

Nested Collections                                                                       

Dictionary Comprehensions                                                       

8.3 Sets                                                                                           

Set Basics                                                                                      

Set Operations                                                                             

Set Efficiency                                                                                

Set Example: Lottery

Chapter 9 Recursion

9.1 Thinking Recursively                                                             

A Nonprogramming Example                                                    

Iteration to Recursion                                                                 

Structure of Recursive Solutions                                               

Reversing a File                                                                            

The Recursive Call Stack

9.2  Recursive Functions and Data                                                        

Integer Exponentiation                                                               

Greatest Common Divisor                                                          

Directory Crawler                                                                        

9.3  Recursive Graphics                                                                

Cantor Set                                                                                     

Sierpinski Triangle                                                                       

9.4  Recursive Backtracking                                                        

Traveling North/East                                                                   

Eight Queens Puzzle                                                                    

Stopping after One Solution                                                      

9.5  Case Study: Prefix Evaluator                                                          

Infix, Prefix, and Postfix Notation                                             

Evaluating Prefix Expressions

Complete Program

Chapter 10 Searching and Sorting

10.1 Searching and Sorting Libraries                                                    

Binary Search                                                                               



10.2 Program Complexity                                                            

Empirical Analysis

Complexity Classes

10.3 Implementing Searching and Sorting Algorithms                     

Sequential Search                                                                                     

Binary Search                                                                                 

Recursive Binary Search                                                                          

Selection Sort                                                                                             

10.4 Case Study: Implementing Merge Sort                                                

Splitting and Merging lists                                                                      

Recursive Merge Sort                                                                              

Runtime Performance

Hybrid Approach

Chapter 11 Classes and Objects

11.1 Object-Oriented Programming                                                  

Classes and Objects                                                                                 

Date Objects                                                                                               

11.2 Object State and Behavior                                                         

Data Attributes                                                                                         



Accessors and Mutators                                                                          

Making Objects Printable                                                                        

Object Equality and Ordering                                                                  

11.3 Encapsulation                                                                                

Motivation for Encapsulation                                                                 

Private Attributes and Properties                                                          

Class Invariants                                                                                          

11.4 Case Study: Designing a Stock Class                                         

Object-Oriented Design Heuristics                                                        

Stock Attributes and Method Headers

Stock Method and Property Implementation

Chapter 12 Functional Programming

12.1 Functional Programming Concepts                                           

Side Effects                                                                                    

First-Class Functions                                                                                

Higher-Order Functions                                                                          

Lambda Expressions                                                                                 

12.2 Functional Operations on Collections                                                  

Using Map                                                                                     

Using Filter

Using Reduce                                                                                

List Comprehensions                                                                    

12.3 Function Closures                                                                         

Generator Functions                                                                   

Lazy Evaluation                                                                            

Iterable Objects                                                                           

Generator Expressions                                                                 

12.4 Case Study: Perfect Numbers                                                     

Computing Sums                                                                          

The Fifth Perfect Number

Leveraging Concurrency

Appendix A: Python Summary

Your questions answered

Introducing Pearson+. Reimagined learning, designed for you. Choose from one eText or over 1,500 eTexts and study tools, all in one place, for one low monthly subscription. A new way to buy books that fits your budget. Make the most of your study time with offline access, enhanced search, notes and flashcards — to get organized, get the work done quicker and get results. Plus, with the app, put textbooks in your pocket and learn wherever. It's time to upgrade the textbook and simplify learning, so you can have time to live too.

Pearson eText is an easy-to-use digital textbook available from Pearson+. Make it your own by adding notes and highlights. Download the Pearson+ mobile app to learn on the go, even offline. Listen on the go with our new audiobook feature, available for most titles.

When you choose a plan, you're signing up for a 4-month 'term'. We will charge your payment method each month until your 4-month term has ended. You can turn on auto-renew in My account at any time to continue your subscription before your 4-month term has ended.

When you purchase a Pearson+ subscription, it will last 4 months. Before your initial 4-month term ends, you can extend your subscription by turning auto-renew on in My account. If you turn auto-renew on, we’ll automatically renew your subscription and charge you every month until you turn off auto-renew.

To avoid the next payment charge, make sure you turn auto renewal off 1 day before the auto renewal date. You can subscribe again after auto-renew has been turned off by purchasing another Pearson+ subscription. We use your credit card to renew your subscription automatically. To make sure your learning is uninterrupted, please check your card details before your first monthly payment.

With a Multi Pearson+ subscription plan, you can download up to 5 titles on the Pearson+ app from My list on each of your authorized devices every month.

When you're using your Multi Pearson+ subscription plan in a browser, you can select and read from as many titles as you like.