Practical Programming, Fourth Edition

An Introduction to Computer Science Using Python 3.14

by: Dmitry Zinoviev with Paul Gries, Jennifer Campbell, and Jason Montojo

Published 2026-07-10
Internal code gwpy4
Print status In Print
Pages 400
User level
Keywords
Related titles
ISBN 9798888652046
Other ISBN Channel epub: 9798888652053
Channel PDF: 9798888652053
Kindle: 9798888652053
Safari: 9798888652053
Kindle: 9798888652053
Edition 4
BISACs

Highlight

Classroom-tested by generations of students, this new edition of the popular 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: a language that’s used across industries and platforms. 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.14.

Description

No programming experience required! 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), discover a five-step recipe for designing functions, which helps you learn the concepts—and becomes an integral part of writing programs.

In this detailed introduction to Python and to computer programming, find out exactly what happens when your programs are executed. Work with numbers, text, sequences, and files using real-world examples. Create and use your own data types. Make your programs robust and reliable; develop an idiomatic programming style; download data from the web automatically. As you use the fundamental programming tools in this book, you’ll see how to document and organize your code so that you and other programmers can more easily read and understand it. This new edition takes advantage of Python 3.14’s new features, including f-strings, the walrus operator, and richer type annotations on parameters, return types, and variable declarations.

Most importantly, you’ll learn how to think like a professional programmer.

Contents and Extracts

Table of Contents

  • Working with Text
    • Creating Strings of Characters
    • Using Special Characters in Strings
    • Creating a Multiline String
    • Printing Information
    • Getting Information from the Keyboard
    • Formatted Strings
    • Quotes About Strings
    • Exercises
  • Making Choices
    • A Boolean Type
    • Choosing Which Statements to Execute
    • Nested if Statements
    • Memorizing Results of a Boolean Expression Evaluation
    • You Learned About Booleans: True or False?
    • Exercises
  • A Modular Approach to Program Organization
    • Importing Modules
    • Defining Your Modules
    • Testing Your Code Semiautomatically
    • Tips for Grouping Your Functions
    • Organizing Your Thoughts
    • Exercises
  • Using Methods
    • Modules, Classes, and Methods
    • Calling Methods
    • 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
    • Splitting Strings
    • 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 and Benchmarking Algorithms
    • Searching for the Two Smallest Values
    • Timing the Functions
    • At a Minimum, You Saw This
    • Exercises
  • Searching and Sorting
    • 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
  • Mastering Iteration Tools
    • Core Idioms
    • Functional Programming
    • Built-In and Standard Library Helpers
    • Let’s Reiterate
    • Exercises
  • Handling Exceptions
    • Core Idioms
    • Accessing Exception Details
    • Common Built-in Exceptions
    • Raising and Chaining Exceptions
    • Defining Custom Exceptions
    • Exceptionally Important!
    • Exercises