Most homework and lab assignments are taken from the Python or M2 textbooks.
This page lists amendments and assignments not taken from the textbooks.
Lab 0: Python/IDLE Intro (due Thu 16Sep)
The point of this "Lab 0" is to ensure you have a working development
environment for Python and have familiarity with creating Python (.py) files
and executing them. There is nothing to turn in for this lab, but you need
to make sure you have completed it on time so that you can move on to the first
"real" lab, Lab 1.
Fire up Python!
Python 3 is pre-installed in Windows on the computers in the CSI lab:
go to the Start Menu → Programs → Python → IDLE.
Python is free for you to download and install on your own computer:
go to Python.org and on the left-hand
side, under "Quick Links (3.1.2)", select
"Windows Installer".
There is also a Mac version.
Make sure you have version 3.1.2, not version 2.7!
The differences are slight but noticeable. Our textbook is using Python 3.
You do not have to use IDLE to edit your Python programs if you are
more comfortable with another editor like
VIM or
Eclipse.
But IDLE is highly recommended.
If you choose to install Python on your own computer, you do so at your
own risk, and there will be no "official" support for helping you install it.
Walk through all the examples in the textbook, sections 1.6-1.7
(it's not much!). In particular, make sure you understand how to create a
Python program (in this example, chaos.py), save it, open it, and
run it in IDLE.
That's it! Get ready for Lab 1, the first "real" lab you have to turn in.
Lab 1: Interactive Programs in Python (due Thu 23Sep)
This is your first lab for which you need to turn something in. Make sure you have
completed Lab 0 before starting on this. The options for this assignment are in
the Modula-2 supplemental textbook, available online:
see M2 ch2 §14.
Choose one of the following, but implement it in Python instead of Modula-2:
#35
#36
#40 (just use 3 purchases; no looping required)
#41
You must also write a short lab write-up to go with your Python program;
see the template lab write-up and
rubric of how write-ups are marked.
For this first lab, a simplified write-up is sufficient: you may include just
the sections titled, "Problem", "Problem Suitability", "Problem Restatement",
and output from a few sample runs of your program.
The point breakdown is listed at the very end of the lab write-up rubric page,
under "simplified write-up".
Upload both your program (.py file) and your writeup
(.doc, .odt, .html, .pdf, etc. -- as long as your TA can read it)
to myCourses before 10pm on the due date.
You will want to get started early on this!
Lab 2: Control Structures (due Thu 30 Sep)
From M2 ch3 §14,
choose one of the following, implementing it in Python:
#17
#29
#37
#38
Again for this lab, a simplified write-up is all that's required.
But be prepared, starting from Lab3, all labs must have a complete write-up
with something in every section of the write-up template!
Upload both your program (.py file) and your writeup
(.doc, .odt, .html, .pdf, etc. -- as long as your TA can read it)
to myCourses before 10pm on the due date.
Lab 3: Functions (due Thu 14 Oct)
From M2 ch4 §11,
choose one of the following, implementing it in Python:
#34
#37
#40
#41
Python ch5 (p.162) Programming Exercise #4 (write a function that returns
an acronoym)
Python ch5 (p.163) Programming Exercise #6 (write a function that returns
the numeric value)
Starting from this lab an onward, every lab must have a full lab
write-up, following the format in
the template lab write-up.
You should have something in every section of the template!
Be sure to include output from a few sample runs of your working program,
and try to choose tricky test cases to see how your program behaves with weird
input.
Lab 4: Drawing (due Thu 28 Oct)
The objective of this lab is to gain practice in using Zelle's
graphics.py library to draw basic graphics.
Choose one of the following from the Python textbook ch4 Programming
Exercises:
#2: allow the user to click once to specify the centre of the target,
and click again to specify the radius.
#4
#6
#10
#11
Or programmatically draw a scene of your own design!
There should be some aspect of the scene which depends on user input,
either via clicks or Entry boxes. If in doubt as to whether
your design is of appropriate scope for this lab, just check with me
in advance.
Lab 5: Lists and File I/O (due Wed 10 Nov)
For this lab, you will be building complex data structures like Python
lists and also using file I/O to read or save results to file.
Choose one of the following options:
M2 §7.14 #22:
Your program should read in the list of words from a file specified
by the user (this can also help a lot for debugging!).
M2 §7.14 #43:
Also write a testbed program that can encrypt/decrypt a whole
(text) file, outputting to a new file.
M2 §9.14 #39:
You can use a Python list instead of a "record".
Read the student data in from a file (filename given by user)
rather than getting it interactively from the user.
You don't need to do the median.
M2 §9.14 #40:
Note that your program needs not only to read previous balance
from file, but also to write the new transaction and new balance
to the end of the file -- the file should be a log of all transactions.
Or come up with your own idea which reads in data
from file (storing it in lists), allows adding/deleting/editing
entries, and writes it back out to file. If you want to do your
own idea, please run it by me first (send me an email).
Lab 6: Object-oriented Class (due Thu 2 Dec)
Define an appropriate class and use it to solve one of the following
problems from the Python textbook ch12 Programming Exercises:
#3: define an Attendee class
#4: define a User class; you may also want to define an Account class
#5, #6, or #8: it should be an interactive game, and should use
a class that you define
Or come up with your own idea which involves defining and using
at least one class to store data. If you want to do your own idea, please
run it by me first (send me an email).