In-class examples and more
CIS 180 L
Intro to Python
Fall 2006
Last modified: Wed Nov 1 00:15:12 PST 2006
Important Note:
This is a selection of files and examples, most of which were
mentioned or used in the class sessions. It may not be a comprehensive
list. Formatting is generally minimal.
- Class session 10, 10-26-06: A Taste of GUI's and Python
- for much more, see
Using Python for GUI Development , a link from
www.python.org
-
lect10 IDLE projections
- edited IDLE session projected during lecture,
with some additional hopefully-explanatory comments
-
easyguiEx1.py - EasyGui example from EasyGui
web site,
http://www.ferg.org/easygui/
-
easyguiEx2.py - adding saving responses to a file
to the previous example
- a collection of examples from
http://wiki.wxpython.org/index.cgi/Getting_20Started,
wxPython Wiki, Getting Started subsection
-
wxpython_ex1.py - a simple "hello, world" frame
-
wxpython_ex2.py - a simple frame class
-
wxpython_ex3.py - a simple frame class,
now with some menu items in a menu in a menubar
-
wxpython_ex4.py - a simple frame class,
with a little event handling in some of those
menu items
-
wxpython_ex5.py - a simple frame class,
including an example of a file-selection dialog
box
-
wxpython_ex6.py - a simple frame class,
adding some (non-functional) buttons across the
bottom
-
wxpython_ex7.py - an example showing more
components: text box, radio buttons, check box,
and more
- Class session 9, 10-24-06: Intro to Python objects (but also
a little on system-defined attributes, kind-of-hiding some of
a module's attributes, and how you can use a module's __name__
attribute to help it behave differently when run at the command
line)
-
lect09 IDLE projections
- edited IDLE session projected during lecture,
with some additional hopefully-explanatory comments
-
lect09_1.py - used to demonstrate dir function
-
lect09_2.py - used to demonstrate how from command
doesn't copy over attributes whose names begin with a
single underscore (but import does)
-
lect09_3.py - used to demonstrate how __all__
is another way to limit what the from command copies over
(but, again, not when using import)
-
lect09_4.py - used to demonstrate how __name__
is set differently when a module is called at the command-line
than when imported within python/IDLE
-
lect09_5.py - another __name__ example,
showing it being used to display the results of tests
of a function when it is called at the command-line;
-
lect09_6.py - examples of Python classes: Employee
and Shape
-
lect09_7.py - example of a Python subclass: Chef,
a subclass of Employee
- Class session 8, 10-19-06: Tidbits on docstrings, modules, and
exception-handling
-
lect08 IDLE projections
- edited IDLE session projected during lecture,
with some additional hopefully-explanatory comments
-
lect07.py - previous-lecture's example script
with docstrings added
-
tryMe.py - used in reload() demo (this is the
version AFTER the addition of farewell variable...)
- Class session 7, 10-17-06: Intro to file handling in Python
-
lect07 IDLE projections
- edited IDLE session projected during lecture,
with some additional hopefully-explanatory comments
- lyrics.txt -
example input file used in class examples
-
ends_w_newline.txt -
another example input file used in class examples
-
show_guts.py -
example Python script used to demonstrate that
relative path names are relative to where the
script is *running* - displays the first line of
a file
file1
in the directory from
which this script is run
-
pig_it.py -
demo of Python interactive input - script asks user
to enter a string, and then it displays that string
pig_latinized (needs hw4.py to be in the same directory)
-
lect07.py -
contains two functions - one,
pig_latin_file
,
takes two file names as arguments and writes the
second so it contains a "pig-latinized" version of
the contents of the first, and the other,
letter_freq_file
, displays a simple
horizontal bar chart of the letter frequencies in the
file passed as its one argument. (needs hw4.py and
hw5.py to be in the same directory)
-
open
built-in function -
Python Library Reference: Section 2.1 - Built-in Functions -
scroll down to see description of open built-in function
-
File methods -
from Python Library Reference: Section 3.9 - File Objects
- Class session 6, 10-12-06: intro to Python tuples and dictionaries
- Class session 5, 10-10-06: intro to Python lists
- Class session 3, 10-03-06: intro to Python strings
-
lect03 IDLE projections
- edited IDLE session projected during lecture,
with some additional hopefully-explanatory comments
-
String methods -
Section 3.6.1 from the Python Library Reference: String
Methods
-
String formatting -
Section 3.6.2 from the Python Library Reference: String
Formatting Operations
- Class session 2, 09-28-06: part 2 of Python basics for
C++-or-Java programmers
-
lect02_projected.txt
- some random projected notes from class
-
lect02 IDLE projections
- slightly-edited IDLE session projected during lecture
- numberFun.py -
function syntax reminder: a python module containing a
very simple function
- example.py -
contains two functions, one that returns a value, and
one that does not.
- ex4.py -
contains two functions containing if-statements
- Class session 1, 09-26-06: Intro to Python, part 1 of
Python basics for C++-or-Java programmers
Back to Course Home Page
Please send questions to
st10@humboldt.edu .