Python Programs in the Textbook

Booksite Modules

Below is a table of the booksite modules that we use throughout the textbook and booksite and beyond.

1.5 functions to read/write numbers and text from/to stdin and stdout
1.5 functions to draw geometric shapes
1.5 functions to create, play, and manipulate sound
2.2 functions related to random numbers
2.2 functions to create, read, and write 1D and 2D arrays
2.2 functions to compute and plot statistics
3.1 data type for colors
3.1 data type to process digital images
3.1 data type to read numbers and text from files and URLs
3.1 data type to write numbers and text to files

If you followed the instructions provided in this booksite (for Windows, Mac OS X, or Linux), then the booksite modules are installed on your computer. If you want to see the source code for the booksite modules, then click on the links in the above table, or download and unzip

Programs and Data Sets in the Textbook

Below is a table of the Python programs and data sets used in the textbook. Click on the program name to access the Python code; click on the data set name to access the data set; read the textbook for a full discussion. You can download all of the programs as and the data as

1.1.1 Hello, World
1.1.2 using a command-line argument
1.2.1 string concatenation example
1.2.2 integer operators
1.2.3 float operators
1.2.4 quadratic formula
1.2.5 leap year
1.3.1 flipping a fair coin
1.3.2 your first loop
1.3.3 computing powers of two
1.3.4 your first nested loops
1.3.5 harmonic numbers
1.3.6 Newton's method
1.3.7 converting to binary
1.3.8 gambler's ruin simulation
1.3.9 factoring integers
1.4.1 sampling without replacement
1.4.2 coupon collector simulation
1.4.3 sieve of Eratosthenes
1.4.4 self-avoiding random walks
1.5.1 generating a random sequence
1.5.2 interactive user input
1.5.3 averaging a stream of numbers
1.5.4 a simple filter
1.5.5 standard input to draw filter usa.txt  
1.5.6 bouncing ball
1.5.7 digital signal processing elise.txt  ascale.txt  stairwaytoheaven.txt  entertainer.txt  firstcut.txt  freebird.txt  looney.txt  
1.6.1 computing the transition matrix small.txt  medium.txt  
1.6.2 simulating a random surfer
1.6.3 mixing a Markov chain
2.1.1 harmonic numbers (revisited)
2.1.2 Gaussian functions
2.1.3 coupon collector (revisited)
2.1.4 play that tune (revisited) elise.txt  ascale.txt  stairwaytoheaven.txt  entertainer.txt  firstcut.txt  freebird.txt  looney.txt  
2.2.1 Gaussian functions module
2.2.2 sample Gaussian client
2.2.3 Sierpinski triangle
2.2.4 iterated function systems sierpinski.txt  barnsley.txt  coral.txt  culcita.txt  cyclosorus.txt  dragon.txt  fishbone.txt  floor.txt  koch.txt  spiral.txt  swirl.txt  tree.txt  zigzag.txt  
2.2.5 Bernoulli trials
2.3.1 Euclid's algorithm
2.3.2 towers of Hanoi
2.3.3 Gray code
2.3.4 recursive graphics
2.3.5 Brownian bridge
2.4.1 vertical percolation detection test5.txt  test8.txt  
2.4.2 percolation support functions
2.4.3 vertical percolation visualization client
2.4.4 vertical percolation probability estimate
2.4.5 percolation detection test5.txt  test8.txt  
2.4.6 percolation visualization client
2.4.7 percolation probability estimate
3.1.1 potential gene identification
3.1.2 charged particle client
3.1.3 Albers squares
3.1.4 luminance library
3.1.5 converting color to grayscale mandrill.jpg  mandrill.png  darwin.jpg  darwin.png  
3.1.6 image scaling mandrill.jpg  mandrill.png  darwin.jpg  darwin.png  
3.1.7 fade effect mandrill.jpg  mandrill.png  darwin.jpg  darwin.png  
3.1.8 visualizing electric potential charges.txt  
3.1.9 concatenating files in1.txt  in2.txt  
3.1.10 screen scraping for stock quotes
3.1.11 splitting a file djia.csv  
3.2.1 charged-particle data type
3.2.2 stopwatch data type
3.2.3 histogram data type
3.2.4 turtle graphics data type
3.2.5 Koch curve
3.2.6 spira mirabilis
3.2.7 drunken turtle
3.2.8 drunken turtles
3.2.9 complex number data type
3.2.10 Mandelbrot set
3.2.11 stock account data type turing.txt  
3.3.1 complex numbers (revisited)
3.3.2 counter data type
3.3.3 spatial vector data type
3.3.4 sketch data type genome20.txt  
3.3.5 similarity detection documents.txt  constitution.txt  tomsawyer.txt  huckfinn.txt  prejudice.txt  djia.csv  amazon.html  actg.txt  
3.4.1 gravitational body data type
3.4.2 n-body simulation 2body.txt  3body.txt  4body.txt  2bodytiny.txt  
4.1.1 3-sum problem 8ints.txt  1kints.txt  2kints.txt  4kints.txt  8kints.txt  16kints.txt  32kints.txt  64kints.txt  128kints.txt  
4.1.2 validating a doubling hypothesis
4.1.3 timing operators and functions
4.1.4 discovering memory capacity
4.2.1 binary search (20 questions)
4.2.2 binary search (inverting a function)
4.2.3 binary search (sorted array) emails.txt  white.txt  
4.2.4 insertion sort tiny.txt  tomsawyer.txt  
4.2.5 doubling test for sorting functions
4.2.6 mergesort tiny.txt  tomsawyer.txt  
4.2.7 frequency counts leipzig100k.txt  leipzig200k.txt  leipzig1m.txt  
4.3.1 stack (resizing array implementation) tobe.txt  
4.3.2 stack (linked list implementation) tobe.txt  
4.3.3 expression evaluation expression1.txt  expression2.txt  
4.3.4 queue (linked list implementation) tobe.txt  
4.3.5 M/M/1 queue simulation
4.3.6 load balancing simulation
4.4.1 dictionary lookup amino.csv  djia.csv  elements.csv  ip.csv  ip-by-country.csv  morse.csv  phone-na.csv  
4.4.2 indexing mobydick.txt  tale.txt  
4.4.3 hash symbol table data type
4.4.4 BST symbol table data type
4.5.1 graph data type tinygraph.txt  
4.5.2 using a graph to invert an index tinygraph.txt  movies.txt  
4.5.3 shortest-paths client routes.txt  movies.txt  
4.5.4 shortest-paths client
4.5.5 small-world test tinygraph.txt  
4.5.6 performer-performer graph tinymovies.txt  moviesg.txt