This section contains the labs that were done during class, along with example solutions, and a small section of miscellaneous items.

Labs and Solutions

Lab 3 covered control flow with if-elif-else statements. (PDF)  
Lab 4 covered control flow with while statements. (PDF) (PY) (PY) (PY)

Lab 5 covered the use of lists in storing a dynamic number of values. (PDF) (PY) (PY)

Lab 6 covered the use of tuples instead of lists and their similarity with strings. (PDF) (PY) (PY)

Lab 7 was a walkthrough tutorial that introduced the idea of objects as opposed to primitive types like ints and floats. By exploring concepts like primitives (e.g. numbers) versus references to objects (e.g. lists), mutability versus immutability, and the effects of scope on objects, we now better understand how to use objects correctly.


1. Some commands will not produce the expected results when performed on the shell. Instead, run the commands from a file. I'm not sure why this is.

2. I was under the impression that Python aliases tuples automatically. It turns out this is not the case. In other words:

a = (1, 2, 3)
b = (1, 2, 3)
print a is b

However, you can still alias by saying b = a. Strings are still automatically aliased.

Lab 8 covered the use of member functions in various objects. (PDF) (PY)
Lab 9 covered the use and syntax of dictionaries. The bulk of the lab was to explore one common use of dictionaries as indexes, in this case, for searching the Web.

(PDF) (PY) (PY) (PY) (PY)

smallsites.txt (TXT)

mitsites20.txt (TXT)

mitsites50.txt (TXT) (ZIP) (PY) (PY)

Lab 10 covered a more advanced use of dictionaries. The bulk of the lab was to improve the web indexer we built in the previous lab.

(PDF) (PY) (PY) (PY) (PY) (PY)



Optional Assignment (PDF): This walks you through the building of a computer from scratch. Starting at the gate level, you'll understand how a computer works.

Operator Cheat Sheet (PDF): This lists some of the various arithmetic and boolean (comparison, equality, and logic) operators we've learned.