This course uses Think Python 2nd Edition by Allen B. Downey, which is available in HTML and PDF for free. You can also buy the paperpack at Amazon.com.

Table of Contents

The way of programming

+

What is a program?

Running Python

The first program

Arithmetic operators

Values and types

Formal and natural languages

Variables, expressions and statements

+

Assignment statements

Variable names

Expressions and statements

Script mode

Order of operations

String operations

Comments

Fuctions

+

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?

Case study: interface design

+

The turtle module

Simple repetition

Encapsulation

Generalization

Interface design

Refactoring

A development plan

docstring

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

Fruitful functions

+

Return values

Incremental development

Composition

Boolean functions

More recursion

Leap of faith

One more example

Checking types

Iteration

+

Reassignment

Updating variables

The while statement

break

Square roots

Algorithms

Strings

+

What is a string?

Traversing a string

String operations

Strings are immutable

Searching

Looping and counting

String methods

The in operator

String comparison

Case study: word play

+

Reading word lists

Search

Looping with indices

Lists

+

What is a list?

Traversing a list

List operations

Map, filter and reduce

Deleting elements

Lists and strings

Objects and values

Aliasing

List arguments

Dictionaries

+

What is a dictionary?

A collection of counters

Traversing a dictionary

Reverse lookup

Dictionaries and lists

Memos

Global variables

Tuples

+

What is a tuple?

Tupple assignment

Tuples as return values

Variable-length arument tuples

Lists and tuples

Dictionaries and tuples

Sequencies of sequencies

Case study: data structure selection

+

Word frequency analysis

Random numbers

Word histogram

Most common words

Optional parameters

Dictionary substraction

Random words

Markov analysis

Data structures

Files

+

Persistence

Reading and writing

Format operator

Filenames and paths

Catch exceptions

Databases

Pickling

Pipes

Writing modules

Classes and objects

+

Customized types

Attributes

Rectangles

Instances and return values

Objects are mutable

Copying

Classes and functions

+

Time

Pure functions

Modifiers

Prototyping vs planning

Classes and methods

+

Object-oriented features

Printing objects

The init method

The __str__ method

Operator overloading

Type-based dispatch

Polymorphism

Inheritance

+

Card objects

Class attributes

Comparing cards

Decks

Printing the deck

Add, remove, shuffle and sort

Inheritance

Class diagrams

Goodies

+

Conditional expressions

List compressions

Generator expressions

any and all

Sets

Counters

defaultdict

Named tuples

Gathering keyword args

Resources and Tools

+

Resources

Tools