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)||
|Lab 5 covered the use of lists in storing a dynamic number of values.||(PDF)||
|Lab 6 covered the use of tuples instead of lists and their similarity with strings.||(PDF)||
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:
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)||genetic.py (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.||
|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.||
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.