Table of Contents¶
Workspace¶
General Introduction¶
- Introduction: The Way of the Program
- Algorithms
- The Python Programming Language
- Special Ways to Execute Python in this Book
- More About Programs
- What is Debugging?
- Syntax errors
- Runtime Errors
- Semantic Errors
- Experimental Debugging
- Formal and Natural Languages
- A Typical First Program
- Comments
- Glossary
Simple Python Data¶
- Introduction: Values, Operators, Function calls, Variables
- Values and Data Types
- Operators and Operands
- Function Calls
- Data Types
- Type conversion functions
- Variables
- Variable Names and Keywords
- Statements and Expressions
- Order of Operations
- Boolean Values and Boolean Expressions
- Logical operators
- Precedence of Operators
- Reassignment
- Updating Variables
- Hard-Coding
- Input
- Glossary
- Exercises
Debugging¶
Object Instances¶
Sequences¶
- Introduction: Sequences
- Strings
- Operations on Strings
- Index Operator: Working with the Characters of a String
- Operations and Strings
- String Methods
- Length
- The Slice Operator
- Strings are Immutable
- The
in
andnot in
operators - Character classification
- Lists
- List Values
- List Length
- Accessing Elements
- List Membership
- Concatenation and Repetition
- List Slices
- Lists are Mutable
- List Deletion
- Objects and References
- Aliasing
- Cloning Lists
- List Methods
- Append versus Concatenate
- Splitting and Joining Strings
- Summary
- Exercises
- Extra Exercises
Iteration¶
- Introduction: Iteration
- The for Loop
- Flow of Execution of the for Loop
- Strings and
for
loops - Traversal and the
for
Loop: By Index - Lists and
for
loops - What You Can Iterate Over
- The Accumulator Pattern
- The Accumulator Pattern with Lists
- The Accumulator Pattern with Strings
- Glossary
- Exercises
- Extra Exercises
Conditionals¶
Files¶
Understanding Code¶
Dictionaries¶
Accumulating Results in Dictionaries¶
Building Programs¶
Functions¶
- Function Definition
- Function Invocation
- Function Parameters
- Returning a value from a function
- A function that accumulates
- Decoding a Function
- Method Invocations
- Variables and parameters are local
- Global Variables
- Functions can call other functions
- Flow of Execution Summary
- Print vs. return
- Passing Mutable Objects
- Side Effects
- Glossary
- Extra Exercises
Optional and Keyword Parameters¶
Tuples¶
Nested Data and Nested Iteration¶
Sorting¶
Python Modules¶
Internet APIs¶
- The Internet: Behind the Scenes
- Requesting data from the Internet
- Anatomy of URLs
- The HTTP protocol
- Fetching a page
- More Details of the Requests Module
- Generating Request URLs
- Debugging calls to requests.get()
- Functions with REST APIs
- Requests Cookbook
- Searching for Media on iTunes
- Searching for tags on flickr
- Unicode for non-English characters
- Caching Response Content
- A Pattern for Caching
String Formatting¶
Native Interpreter Gotchas¶
Classes¶
- Introduction: Classes and Objects - the Basics
- Objects Revisited
- User Defined Classes
- Adding Parameters to the Constructor
- Adding Other Methods to a Class
- Objects as Arguments and Parameters
- Converting an Object to a String
- Instances as Return Values
- Sorting Lists of Instances
- Class Variables and Instance Variables
- Thinking About Classes and Instances
- Defining Classes with Data from the Internet
- A Tamagotchi Game
- Glossary
- Exercises
- Extra Exercises