Lab Materials
Labs are held every week, during section. Times, places, and lab instructors are listed on the Times & Places page.
You will not be graded on your performance during
lab, though you are expected to do them. Up to two labs may be missed; any more unexcused absences
and we reserve the right to reduce your course grade (e.g. B goes to B-).
Lab descriptions and files are listed in the table below.
Lab |
Topic |
References |
Code |
Lab 1
|
Evaluating Expressions
The purpose of this lab is two-fold: (a) to get you started
with Python immediately; (b) to give you hands-on experience with
expressions, the topic of the first lecture.
|
|
|
Lab 2
|
Functions, Strings, and Modules
The purpose of this lab is to get you comfortable with using Python functions
and modules. Python has a lot of built-in modules, which collectively are called
the Python library. You'll also practice more with string processing.
|
Reference for dealing with the command line |
|
Lab 3
|
Objects, Functions, and Testing
We practice testing functions, some related to objects.
|
|
transcript.py
|
testtranscript.py
|
cornelltest.py
|
Lab 4
|
No lab - Feb break
|
|
|
Lab 5
|
Lists; Conditionals: Cards and Poker Hands
We practice with lists and conditionals by considering lists of Card objects, enabling us to draw poker hands.
|
List operations |
cardstuff.py
|
cardstufftest.py
|
Lab 6
|
An anagram solver: lists, for-loops, map, command-line arguments, accessing files
We write a program that accomplishes a pretty non-trivial task: finding anagrams. The program makes use of an insight about representing strings, storing strings and their “letter-sorted” in lists for easy access.
|
Sections 10.3, 10.7 |
unscramble.py
|
unscrambletest.py
|
scowl_utf-8.txt
|
small_dict.txt
|
Lab 7
|
Office hours/work on lab 6
No new lab exercise; on Tuesday you can come to work on lab 6 or ask questions of the staff
during your prelim preparation, or not come at all. Don't come on Wednesday; no one wil be there.
|
|
|
Lab 8
|
Recursion Exercises
This lab gives you practice writing recursive functions. All
of the functions in this lab are either be recursive functions on
sequences, or recursive functions on integer.
|
Sections 5.8 - 5.10 |
lab08.py
|
test_lab08.py
|
Lab 9
|
Classes: Blackjack
You'll practice writing a class definition, in the context of
a program that allows you to play blackjack.
The module skeleton also contains a while-loop,
which you may wish to gaze upon now and which we'll learn about later.
|
Chapters 15-17.6 |
blackjack.py
|
card.py
|
test_blackjack.py
|
Lab 10
|
Loop Exercises
Practice with loop assertions
(preconditions, postconditions, and invariants) and while-loops.
|
Worked exercises on loop invariants |
lab10.py
|
card2.py
|
lab10test.py
|
Lab 11
|
Sequence Algorithms
This lab gives you practice developing loops from invariants, material that will be important for Prelim 2. It also contains an optional exercise about a sorting algorithm, which you may want to delay until later, when your studying for the final exam.
|
Worked exercises on loop invariants |
|
Lab 12
|
Office hours Tuesday/nobody there Wed
The Tuesday labs will be office hours for last-minute Prelim 2 questions; the Wednesday labs are canceled completely (no staff will be there).
|
|
|
Lab 13
|
Subclasses
This lab gives you some practice with writing a subclass and using exceptions to your advantage.
|
Chapter 17; Chapter 18 (especially 18.7); 14.5 |
card.py
|
extendedcard.py
|
Lab 14
|
Optional office hours
On Tuesday and Wednesday you can come work on Breakout or ask questions to prepare for the final, or not come at all.
|
|
|
|