Lecture Slides
The slides from lecture are provided as .pdf files,
convenient for printing.
Some of them are accompanied by the example Python programs we
write in class.
To put the example Python programs onto your computer
(at least in Windows), right-click on the link for the program
and select "Save target as.." or "Save as..".
The same goes for data files.
-
Mon 1/7 slides. Read Chapter 1 in the
textbook.
The first program
is due on Thursday at 10pm.
-
Wds 1/9 slides.
-
Fri 1/11 slides. The second program is due Thurs Jan 17 at 10pm.
-
Mon 1/14 slides.
guessNum.py, inputCheck.py
-
Wds 1/16 slides.
retire.py
-
Fri 1/18 slides.
monthly.py, gettingFloat.py
-
Wds 1/23 slides.
We did not actually cover the break statement in class.
-
Fri 1/25 slides.
Midterm review.
-
Wds 1/30 slides.
Break, continue, nested loops, storing data in a list.
Counting the number of flips to get 10 heads.
countFlips.py
-
Fri 2/1 slides.
Lists and strings are sequences, the in operator, reading and printing a file.
readFile.py, and input file menu.txt
-
Mon 2/4 slides.
Extracting data from a line in a file, intro to temperature assignment.
calorieCounter.py,
and input file menu.txt
-
Wds 2/6 slides.
Filecabinet metaphore for lists, lists are mutable, writing a file.
listOZeros.py,
countFlipsWriteFile.py
-
Fri 2/8 slides.
For loops, on lists, strings, ranges.
-
Mon 2/11 slides.
For loop on a file, the try-except construction, getting data into
and out of functions.
readCIA.py,
inputCheck.py
-
Wds 2/13 slides.
Homework questions, local variables in functions.
Python Tutor function example
-
Fri 2/15 slides.
Multiple inputs and output for functions. Designing a program as
as collection of functions. Lists as function parameters.
reportRep.py, and
input file reps.tex.
Try filling in the stub for the getDistrict function. And, how can
you make it run until the user enters the empty string, instead
of five times?
-
Here are some Python Tutor
exercises that we will go over in Tuesday lab hours (12-2, 75 Hutchinson).
These review material from the first part of the course.
-
Wds 2/20 slides.
Dictionaries.
reportRepDictionary.py, and
input file reps.tex.
-
Fri 2/22 slides.
Counting events with a dictionary, for loop on a dictionary.
tweeterCounter.py, and
input file tweets.tex
-
Mon 2/25 slides.
List of tuples, and sorting.
tweeterCounterSort.py, and
input file tweets.tex
This program includes a for loop puting the information in a dictionary
into a list of tuples. Can you write a loop that would take the
list of tuples and put the information back into a new dictionary?
-
Wds 2/27 slides.
Review for midterm. How to attack a programming problem, function input
and output, using a dictionary.
Try writing a program for the (difficult) programming problem.
-
More Python Tutor examples. You could use
these to help prepare for Friday's midterm.
-
Mon 3/4 slides.
How dictionaries work; they're a fancy way of indexing a list of
tuples.
poser.py implements a simple version of this
idea. This simple version would run into trouble if two numbers led to the
same index. Can you think of a way to handle cases like this? Probably
anything you think of is used in practice.
-
Wds 3/6 slides.
How Web browsers work.
lameBrowser.py, world's lamest Web browser.
Crashes if you give it a bad URL. Can you fix this using the
try-except construction? How will you change the
program to do something reasonable when it gets a bad URL? Remember only
one line, the line that might cause the crash, should go into the block under
the try (maybe along with a break or something).
-
Fri 3/8 slides.
Object-oriented programming and the tkinter module.
testWindow.py draws some stuff
on a canvas. In addition to this mostly good tutorial on tkinter,
there is also better information on the
canvas object available on the Web; search for tkinter canvas.
-
Mon 3/11 slides.
Discussion of programming problems, dictionary design, when to use
a list of tuples.
More on tkinter components, keyword arguments, callback functions,
and arranging components in the window.
guiComponents.py demonstrates, using
image file Rhododendrum.gif.
-
Wds 3/13 slides.
Global variables and using them in button callbacks.
flowerSlideshow.py, with images
Rhododendrum.gif, Camellia.gif, Columbine.gif.
-
Fri 3/15 slides.
A difficult programming problem, and a glimpse of object oriented
programming from the inside.
deckOfCards.py defines three
classes, a card, a hand and a deck.
-
Mon 3/18 slides.
Review for final, including solutions to two of the extra programming
problems.