Table of Contents

All 21 chapters and 130 sections, in seven parts. Page numbers are the printed book’s. Chapters marked free are included in the sample PDF; chapters marked with an exercise count link straight to that chapter’s Find the Bug set on this site.

Part I · Basic Concepts

1Mathematical Conceptsfree sample

  • 1.1Logic
  • 1.2Set
  • 1.3Integers and Modular Arithmetic
  • 1.4Variables
  • 1.5Composition
  • 1.6Sequences and Patterns
  • 1.7Counting
  • 1.8Algorithms
  • 1.9Graphs and Trees
  • 1.10Binary Numbers
  • 1.11Boolean Values
  • 1.12Hashing
  • 1.13Recursion

2Problem Solvingfree sample

  • 2.1Pseudocode
  • 2.2From Pseudocode to a Python Program
Part II · Computers and Programming

3Computers

  • 3.1Programming Paradigms

4Language Fundamentals

  • 4.1A Brief History
  • 4.2A Python Program
  • 4.3How a Python Program Runs on a Computer
Part III · Data and Operations

5Data Structures50 exercises

  • 5.1Basic Data Types
  • 5.2Advanced Data Types
  • 5.3Quick Guide in Choosing Data Structure
  • 5.4Variables and Types
  • 5.5Find the Bug Exercises

6Objects25 exercises

  • 6.1Classes
  • 6.2Instance Data vs Class Data
  • 6.3Duck Typing
  • 6.4Takeaway
  • 6.5Lists
  • 6.6Copying a List
  • 6.7Find the Bug Exercises

7Operators25 exercises

  • 7.1Arithmetic Operators
  • 7.2Assignment Operator
  • 7.3Comparison Operators
  • 7.4Boolean Operators
  • 7.5Other Operators
  • 7.6Find the Bug Exercises

8Input and Output5 exercises

  • 8.1Find the Bug Exercises
Part IV · Control Flow

9Control Flow55 exercises

  • 9.1if, elif, else
  • 9.2Common Comparison Operators
  • 9.3Logical Operators
  • 9.4for Loops
  • 9.5range
  • 9.6while Loops
  • 9.7break
  • 9.8continue
  • 9.9pass
  • 9.10match case
  • 9.11Functions and return
  • 9.12Find the Bug Exercises

10Functions60 exercises

  • 10.1Your First Function
  • 10.2Parameters
  • 10.3Returning a result
  • 10.4Default Arguments
  • 10.5Keyword Arguments
  • 10.6Multiple Return Values
  • 10.7Implicit None Return
  • 10.8Docstrings
  • 10.9*args and **kwargs
  • 10.10Lambdas
  • 10.11Mutable Default Argument Trap
  • 10.12Pass by Reference vs Pass by Sharing
  • 10.13Find the Bug Exercises

11Scoping30 exercises

  • 11.1A Simple Way to Think about Scopes
  • 11.2Find the Bug Exercises
Part V · Simple and Complex Programs

12A Python Program

  • 12.1Statements
  • 12.2Main Function
  • 12.3Other Functions
  • 12.4Running a Python Program
  • 12.5Reserved Keywords

13Modules10 exercises

  • 13.1Python Standard Library
  • 13.2Writing Your Own Module
  • 13.3Find the Bug Exercises

14Packages

  • 14.1Structure
  • 14.2Do Not Reinvent the Wheel
Part VI · Quality

15Defining Quality

16Handling Failures20 exercises

  • 16.1Example 1: Handling Bad User Input
  • 16.2Example 2: Handling Different Kinds of Errors
  • 16.3Example 3: Using else
  • 16.4Example 4: Using finally
  • 16.5Find the Bug Exercises

17Testing15 exercises

  • 17.1Why Test Python Functions
  • 17.2Testing with Pytest
  • 17.3Helpful Tips
  • 17.4Find the Bug Exercises

18Bugs20 exercises

  • 18.1Types of Bugs
  • 18.2How to Avoid Bugs
  • 18.3Basic Debugging: Find and Fix Bugs
  • 18.4Find the Bug Exercises
Part VII · Tools of the Trade

19Tools

  • 19.1Editor
  • 19.2Running Your Program
  • 19.3Testing and Debugging

20Common Pitfalls130 exercises

  • 20.1Forgetting the : after if, for, while, or def
  • 20.2Using the wrong indentation
  • 20.3Confusing Assignment with Equality
  • 20.4Using a variable before it is created
  • 20.5Misspelling variable names
  • 20.6Mixing strings and numbers without converting types
  • 20.7Forgetting to convert input() to a number
  • 20.8Using / when you want a whole-number result
  • 20.9Using ^ for powers instead of **
  • 20.10Modifying a list item that does not exist
  • 20.11Going past the end of a list
  • 20.12Using parentheses instead of brackets for lists
  • 20.13Forgetting that strings are immutable
  • 20.14Using is instead of == for value comparison
  • 20.15Forgetting to call a function with parentheses
  • 20.16Not returning a value from a function
  • 20.17Changing a global variable inside a function by accident
  • 20.18Forgetting to close a file
  • 20.19Using broad except: and hiding errors
  • 20.20Comparing text without thinking about case
  • 20.21Using range(len(...)) when iterating over items directly is simpler
  • 20.22Shadowing built-in names like list, str, or sum
  • 20.23Expecting floating-point math to be exact
  • 20.24Writing long code without testing small pieces
  • 20.25Shallow vs Deep Copy
  • 20.26Mutable Default Arguments
  • 20.27Find the Bug Exercises

21Find the Bug: Solutions

  • 21.1Data Structures
  • 21.2Objects
  • 21.3Operators
  • 21.4Input and Output
  • 21.5Control Flow
  • 21.6Functions
  • 21.7Scoping
  • 21.8Modules
  • 21.9Handling Failures
  • 21.10Testing
  • 21.11Bugs
  • 21.12Common Pitfalls

Index

The book also carries a preface, a list of figures, a list of tables, and a full index. This listing is generated directly from the book’s own typeset table of contents, so it stays in step with the manuscript.

results matching ""

    No results matching ""