Fork me on GitHub

Project Notes

#285 Python

Book notes - Think Python, 2nd edition, by Allen B. Downey, published by O’Reilly.

Notes

Table of Contents - Highlights

Preface

  • The Strange History of This Book
  • Conventions Used in This Book
  • Using Code Examples
  • O’Reilly Online Learning
  • How to Contact Us
  • Acknowledgments
  • Contributor List
  1. The Way of the Program
  • What Is a Program?
  • Running Python
  • The First Program
  • Arithmetic Operators
  • Values and Types
  • Formal and Natural Languages
  • Debugging
  • Glossary
  • Exercises
  1. Variables, Expressions and Statements
  • Assignment Statements
  • Variable Names
  • Expressions and Statements
  • Script Mode
  • Order of Operations
  • String Operations
  • Comments
  • Debugging
  • Glossary
  • Exercises
  1. Functions
  • Function Calls
  • Math Functions
  • Composition
  • Adding New Functions
  • Definitions and Uses
  • Flow of Execution
  • Parameters and Arguments
  • Variables and Parameters Are Local
  • Stack Diagrams
  • Fruitful Functions and Void Functions
  • Why Functions?
  • Debugging
  • Glossary
  • Exercises
  1. Case Study: Interface Design
  • The turtle Module
  • Simple Repetition
  • Exercises
  • Encapsulation
  • Generalization
  • Interface Design
  • Refactoring
  • A Development Plan
  • docstring
  • Debugging
  • Glossary
  • Exercises
  1. Conditionals and Recursion
  • Floor Division and Modulus
  • Boolean Expressions
  • Logical Operators
  • Conditional Execution
  • Alternative Execution
  • Chained Conditionals
  • Nested Conditionals
  • Recursion
  • Stack Diagrams for Recursive Functions
  • Infinite Recursion
  • Keyboard Input
  • Debugging
  • Glossary
  • Exercises
  1. Fruitful Functions
  • Return Values
  • Incremental Development
  • Composition
  • Boolean Functions
  • More Recursion
  • Leap of Faith
  • One More Example
  • Checking Types
  • Debugging
  • Glossary
  • Exercises
  1. Iteration
  • Reassignment
  • Updating Variables
  • The while Statement
  • break
  • Square Roots
  • Algorithms
  • Debugging
  • Glossary
  • Exercises
  1. Strings
  • A String Is a Sequence
  • len
  • Traversal with a for Loop
  • String Slices
  • Strings Are Immutable
  • Searching
  • Looping and Counting
  • String Methods
  • The in Operator
  • String Comparison
  • Debugging
  • Glossary
  • Exercises
  1. Case Study: Word Play
  • Reading Word Lists
  • Exercises
  • Search
  • Looping with Indices
  • Debugging
  • Glossary
  • Exercises
  1. Lists
  • A List Is a Sequence
  • Lists Are Mutable
  • Traversing a List
  • List Operations
  • List Slices
  • List Methods
  • Map, Filter and Reduce
  • Deleting Elements
  • Lists and Strings
  • Objects and Values
  • Aliasing
  • List Arguments
  • Debugging
  • Glossary
  • Exercises
  1. Dictionaries
  • A Dictionary Is a Mapping
  • Dictionary as a Collection of Counters
  • Looping and Dictionaries
  • Reverse Lookup
  • Dictionaries and Lists
  • Memos
  • Global Variables
  • Debugging
  • Glossary
  • Exercises
  1. Tuples
  • Tuples Are Immutable
  • Tuple Assignment
  • Tuples as Return Values
  • Variable-Length Argument Tuples
  • Lists and Tuples
  • Dictionaries and Tuples
  • Sequences of Sequences
  • Debugging
  • Glossary
  • Exercises
  1. Case Study: Data Structure Selection
  • Word Frequency Analysis
  • Random Numbers
  • Word Histogram
  • Most Common Words
  • Optional Parameters
  • Dictionary Subtraction
  • Random Words
  • Markov Analysis
  • Data Structures
  • Debugging
  • Glossary
  • Exercises
  1. Files
  • Persistence
  • Reading and Writing
  • Format Operator
  • Filenames and Paths
  • Catching Exceptions
  • Databases
  • Pickling
  • Pipes
  • Writing Modules
  • Debugging
  • Glossary
  • Exercises
  1. Classes and Objects
  • Programmer-Defined Types
  • Attributes
  • Rectangles
  • Instances as Return Values
  • Objects Are Mutable
  • Copying
  • Debugging
  • Glossary
  • Exercises
  1. Classes and Functions
  • Time
  • Pure Functions
  • Modifiers
  • Prototyping versus Planning
  • Debugging
  • Glossary
  • Exercises
  1. Classes and Methods
  • Object-Oriented Features
  • Printing Objects
  • Another Example
  • A More Complicated Example
  • The init Method
  • The str Method
  • Operator Overloading
  • Type-Based Dispatch
  • Polymorphism
  • Interface and Implementation
  • Debugging
  • Glossary
  • Exercises
  1. Inheritance
  • Card Objects
  • Class Attributes
  • Comparing Cards
  • Decks
  • Printing the Deck
  • Add, Remove, Shuffle and Sort
  • Inheritance
  • Class Diagrams
  • Data Encapsulation
  • Debugging
  • Glossary
  • Exercises
  1. The Goodies
  • Conditional Expressions
  • List Comprehensions
  • Generator Expressions
  • any and all
  • Sets
  • Counters
  • defaultdict
  • Named Tuples
  • Gathering Keyword Args
  • Glossary
  • Exercises
  1. Debugging
  • Syntax Errors
  • I keep making changes and it makes no difference.
  • Runtime Errors
  • My program does absolutely nothing.
  • My program hangs.
  • When I run the program I get an exception.
  • I added so many print statements I get inundated with output.
  • Semantic Errors
  • My program doesn’t work.
  • I’ve got a big hairy expression and it doesn’t do what I expect.
  • I’ve got a function that doesn’t return what I expect.
  • I’m really, really stuck and I need help.
  • No, I really need help.
  1. Analysis of Algorithms
  • Order of Growth
  • Analysis of Basic Python Operations
  • Analysis of Search Algorithms
  • Hashtables

Getting the Example Source

git clone https://github.com/AllenDowney/ThinkPython2.git example_source

Credits and References

About LCK#285 pythonbook
Project Source on GitHub Return to the Project Catalog

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.

LittleArduinoProjects LittleModelArt More on my blog