Safari. This is a full-text
database of technical books, including everything published by O'Reilly
Press. You can find a number of books here on computer topics, including
several books on Python.
The Python Web Site (for news, software
and documentation. If you want to download Python onto your own computer
this is a place to find it.)
Here is a reference on Tkinter, the graphical interface system we are
using. This
is a link to a web-based version of iit, and
this is the actual document in PDF format.
Here is a brief document I wrote on the tk
widgets we will use:
2.4.08: first.py This is a simple program
that reads names and prints greetings
2.6.08 rectangles.py This computes
the area of a rectangle
name_age.py: This gets a name and age from the user and prints them
out.
2.8.08 format.py This shows how to use
formatted strings to print a table in columns digits.py
This gets a number from the user and says how many digits it has
2.11.08 We had quite a few programs today, all working with IF statements bobFinder.py lets the user enter a
string and says if that string starts with the word "bob" firstAndLast.py lets the user enter
a string and says if that string starts and ends with the same letters leaper.py
lets the user enter a year and says if that is a leap year looper.py
gets into an infinite loop. Use <CTRL-C> to stop a running program. rumple.py
has the user enter names until the user enters "Rumplestiltskin"
2.13.08: Example programs with loops: averages.py
We started this on Monday. It lets the user enter numbers and computes
their average hw0.py:
We did this in class as a solution to the first homework assignment summer.py:
This prints random addition problems and checks the user's answers factors.py:
This gets numbers from the user and prints the factors of each
2.15.08: More loop examples fibonacci.py
This computers Fibonacci numbers: each is the sum of the 2 previous Fibonacci
numbers palindrome.py
This reads in a string and says if it is a palindrome
test.py This is a quickie example that illustrates the else-clause
on a while loop
2.18.08 primes1.py: This asks for a
number and says if that number is prime primes2.py:
This asks for a limit and finds prime numbers less than that limit. It
prints the results as a table with 7 columns. primes3.py:
This generates prime numbers until enough have been found. primes3b.py: This
is the same as primes3.py, only it uses a for loop test.py:
This is a small illustration of nested for loops
2.20.08 Calendar.py This prints a
calendar for February, 2008 SendMoney.py
This is a simple examle of functions; Letter.py: Another
example of functions, this time with multiple functions that work together
to print a letter calendarFunction.py: This
rewrites the calendar progarm to have a function PrintMonth that prints
the monthly calendars
2.22.08 silly.py: This is a little, useless,
program for playing with variables in various functions primes1.py This asks the user
for numbers and tests whether they are prime primes2.py
This generates a list of prime numbers perfect.py This generates
a table of perfect numbers (numbers whose factors sum to the number).
2.25.08: code.py: This is the brief version
of the encryption program that we wrote in class; it only works with letters
a, b, c code1.py:
This is a longer version that I showed in class; it handles letters a
to p code2.py:
This is the real thing: it handles all letters, both upper and lower case.
This uses the ord() and chr() functions. dictionary.py:
This searches the dictionary for words with 3 consecutive vowels.
2.27.08: Two programs for working with lists: changer.py
This is a little demo to show how functions can modify lists. namelist.py:
This reads in, sorts, then prints a list of names
2.29.08 NameList.py This inputs names
and stores them in a list; if a name is entered more than
once it only appears in the list once. NameList2.py
This was the class's idea. This is another version of the NameList program.
The first time a name appears it added to the list; the second time a
message
says the name is already in the list. The third time the name is given
the programs
says "Stop it!"
3.3.08 Clubs.py This stores clubs and
their members as a list of lists. minimax.py
This is an example of how a function can return multiple values
3.5.08 Annagrams.py This is
the program that generates anagrams. If you call main() at the end it
generates all anagrams of length 2,
then
length 3, and so forth. If you call main2() it has a loop that asks the
user for words and finds anagrams
of
those words. This needs the dict.txt
file from HW3. simple.py This
is a very simple example of a dictionary. Lettercounts.py
This reads lines of text from the user until it gets a blank line.
At the end it prints the number of a's, b's, etc. it finds.
3.7.08 Acronyms.py This uses a dictionary
data structure to implement "Bob's Acronym Dictionary"
3.10.08 Calendar.py This tells
days of theweek for a given date, and also priints monthly and yearly
calendars
3.12.08 CalendarNotes.py This
adds a note facility to our calendar program NamesAndAges.py
This reads in a list of names and ages of people and prints them out in
age order, with all of the people
of
a given age on the same line.
3.14.08 Debug1.py This tries to print
all of the common factors of 12 and 18, but it prints the number 1 over
and over. Debug2.py
This tries to print the 10 factorial, but it gets the answer wrong. Debug3.py
This tries to compute the average of a list of numbers, but it gets the
answer wrong. Debug4.py
This is supposed to pring 8. In actually prints 8, then "None" What1.py
What does this program print? What2.py We
didn't get to this one in class. What does it do? What3.py ditto.
What does this do? TwoLists.py
This reads in two lists of data from the use. One is a list of names and
years (expected year of graduation). The other
is a list of names and gpas. The program reads both of these into dictionaries,
then uses these dictionaries to print the
average gpa for each year.
3.17.08 FirstFile.py is a short program
that reads strings and writes them into a file called "SavedStuff.txt" WriteList.py
does the same thing as FirstFile.py, only it correctly adds a "\n"
character to the end of each line. PrintMe.py
is another short program that reads itself and prints itself to the screen.
3.21.08 FileReader.py reads a file
of numbers into a list, then computes the average of the list. SuffixFinder.py reads the dictionary
file dict.txt and finds all words that
end in a given suffix; the output is printed to a file.
3.31.08 DataReader2.py is just
like FileReader.py from 3.21, only it reads a file with 2 columns of numbers
and prints the average of each column. Here
is a data file for it. try.py
is a little program that demonstrates how to get standard input from a
file rather than from the keyboard. It reads file data.txt. PrimesFrom2.18.py
is an old program from February that prints tables of prime numbers. This
version outputs to a file rather than to your screen.
4.2.08 Calendar.py: This is an update
of our CalendarNotes program (from March 12) that now saves the notes
in a file. FirstClass.py
This is our first example of an "object-oriented" program
that defines a class and constructs objects of that class.
4.4.08: SecondClass.py This is like
the FirstClass example from 4/2, only it adds a constructor function to
the Person Class PeopleWithMarriage.py
This has another Person class with a few additions: it allows one
Person to marry another, it maintains a
list
of persons as they are constructed, and it uses a class variable to keep
track of the number of Persons that have
been
constructed.
4.7.08 Gradebook.py This is an object-oriented
version of the gradebook program you wrote for HW4.
4.9.08 Name.py is a module that defines
class Name but does not contain a whole program. TestName.py
is a program that uses this class. Gradebook.py
is a final version of our gradebook program that uses the Name class defined
in Name.py Money2.py
is a program that illustrates how to implement the arithmetic operators
+, -, * and / for classes.
4.11.08 People.py is another illustration
of implementing arigthmetic operators. This time the class is Person,
and the * operator means that
two
persons have a child.
The
next two examples show how to sort a list whose elements are classes.
Both refer to class Foo.
In
Foo.py we define a < operator for the
class; this allows the usual list.sort() method to work.
In
Foo2.py we define key functions and specify
them when we sort the list. The list is sorted in order of increasing
values of the key.
4.14.08 SimpleSubclass.py illustrates
classes and subclasses. Class B is a subclass of class A. People.py
has a base class Person, with subclasses Student and WorkingStiff. The
latter class has
a
subclass Slacker.
4.16.08 PayPeriods.py is another
illustration of classes and subclasses. SquaresAndCircles.py
is a first graphics program that creates a drawing window and also classes
Square and Circle to draw into it.
4.18.08 NewSquaresAndCircles.py
is another version of the SquaresAndCircles program. This one starts
with classes for Rectangle and Oval and we refined it by making additional
classes for Square and Circle. Face.py
is essentiall the SquaresAndCircles program modified to draw a face SimpleMenu.py
Illustrates the way we create buttons and menus Triangle.py
Illustrates the way we can create arbitrary polygons
4.21.08 FileDisplay.py This has
an entry box, a button and a text widget. When you type a file name in
the entry box and click on the button, the file contents will be displayed
in the text widget.
4.23.08 SimpleScale.py This creates
a scale widget that selects numbers between 1 and 10 and prints them numerically
and in English Polygons.py
This has one scale widget for choosing the number of sides of a polygon
and another for timing
an animation TrafficLight2.py
This uses a scale widget to animate a stop light.
4.25.08 Today we had lots of animation demos BadAnimation.py shows the wrong
way to animate graphics IdleFunction.py
shows the right way to do this, with an Idle function.
RandomWalk.py shows a bunch of small circles moving randomly. They
die when they move off the canvas. TrafficLight3.py has a class for
traffic lights. There is a button that allows the user to create traffic
lights with random size put at random points on the screen. BallsAndWalls.py
has a button to create balls, which move around in an enclosed area and
bounce off the walls. As final exams approach, this simulates the behavior
of many Oberlin students.
4.28.08 BallsAndWallsWithKeys.py
This is the same as the BallsAndWalls program from 4.25, only key-events
have been added. When any key but "q" is pressed a new circle
is created. On "q" the program exits.
4.30.08 FileDisplay.py This is
the FileDisplay program we wrote in class on 4/21. We had a keyboard event
so that when the user hits the Enter key with the mouse inside the entry
box for file names, this has the same effect as clicking the Get File
button. MouseEvents.py
This allows dragging graphical objects with the mouse and also changing
them with keyboard input. GameOfLife.py
This implements John Conway's Game of Life. Running.py
We didn't discuss this one in class, but you might want to play with
it. This is the "freeze tag" game.
5.2.08 Factorial.py This is a recursive
factorial function ListSum.py
This has a recursive function to sum the numbers in a list
5.5.08 Palindrome.py This has a recursive
function to test strings for being palindromes. TowerOfHanoi.py This is a text version
of the game Hanoi.py
This is a graphical version of the game
5.9.08 Here are some little programs to help review for the final: square.py:
Determines whether or not a number is a perfect square Values.py
Has a function that takes a list and makes a new list with each element
of the origianl included only once. py.py
This determines whether a string ends in ".py"
Here are some
programs that interact with the file system. We did not discuss these
in class and they won't be covered on the final. Some of you might enjoy
playing with them. Here is a little
sheet of info about the os module that these use. FileCounter.py
Starts at a folder and counts all of the files below that location. FileFinder.py
Lists all of the files whose names fit a given description DeleteFiles.py
Lists the files fitting a given description. For each one it asks the
user if it should be deleted,
and if the response is "yes" deletes it.