can point them at a log file of real-time streaming stock data.
Software engineers might want to know about design. So, you can have
them look at ways to encapsulate stock data inside an object or making
a program extensible (e.g., how would make this program produce output
in 10 different table formats). You get the idea.
## Presentation Guidelines
The presentation slides (notes) are there to provide a narrative
structure to the course and for reference by students when they work
on exercises. Do not laboriously go over every bullet point on every
slide--assume that students can read and that they will have time to
go back when coding. I tend to go through the slides at a pretty
brisk pace, showing short examples interactively as I go. I often
skip slides entirely in favor of live demos. For example, you don't
really need to do a bunch of slides on lists. Just go to the
interpreter and do some list examples live instead. Rule of thumb: No
more than 1 minute per slide unless it’s something unusually tricky.
Honestly, you could probably skip most of the slides and simply
lecture using live demos if you feel that it works for you. I often
do this.
## Course Exercises
The course has about 130 hands-on exercises. If you do every single
exercise and give students time to think and code, it will likely take
them about 10-12 hours. In practice, you will probably find that students
require more time on certain exercises. I have some notes about this
below.
You should repeatedly emphasize to students that solution code is
available and that it is okay to look at it and copy it--especially
due to time requirements.
Prior to teaching the course, I would strongly advise that you go
through and work every single course exercise so that there are no
surprises.
During course delivery, I usually work every single exercise from
scratch, without looking at the solution, on my computer while the
students also work. For this, I strongly advise you to have a printed
copy of the exercises on hand that you can look at without having to
pull it up on the computer screen (which is being projected). Near
the end of the exercise time period, I will start discussing my
solution code, emphasizes different bits on the screen and talking
about them. If there are any potential problems with the solution
(including design considerations), I’ll also talk about it. Emphasize
to students that they may want to look at/copy solution code before
going forward.
## Section 1: Introduction
The major goal of this section is to get people started with the
environment. This includes using the interactive shell and
editing/run short programs. By the end of the section, students
should be able to write short scripts that read data files and perform
small calculations. They will know about numbers, strings, lists, and
files. There will also be some exposure to functions, exceptions, and
modules, but a lot of details will be missing.
The first part of this course is often the longest because students
are new to the tools and may have various problems getting things to
work. It is absolutely critical that you go around the room and make
sure that everyone can edit, run, and debug simple programs. Make
sure Python is installed correctly. Make sure they have the course
exercises downloaded. Make sure the internet works. Fix anything
else that comes up.
Timing: I aim to finish section 1 around lunch on the first day.
## Section 2 : Working with Data
This section is probably the most important in the course. It covers
the basics of data representation and manipulation including tuples,
lists, dicts, and sets.
Section 2.2 the most important. Give students as much time as
they need to get exercises working within reason. Depending on audience,
the exercises might last 45 minutes. In the middle of this exercise,
I will often move forward to Section 2.3 (formatted printing) and
give students more time to keep working. Together, Sections 2.2/2.3
might take an hour or more.
Section 2.4 has people explore the use of enumerate(), and zip(). I
consider these functions essential so don’t skimp on it.
Section 2.5 introduces the collections module. There is a LOT that
could be said about collections, but it won't be fully appreciated by
students at this time. Approach this more from the standpoint of
"here's this cool module you should look at later. Here are a few cool
examples."
Section 2.6 introduces list comprehensions which are an important
feature for processing list data. Emphasize to students that list
comprehensions are very similar to things like SQL database queries.
At the end of this exercise, I often do an interactive demo involving
something more advanced. Maybe do a list comprehension and plot some
data with matplotlib. Also an opportunity to introduce Jupyter if
you're so inclined.
Section 2.7 is the most sophisticated exercise. It relates to the use
of first-class data in Python and the fact that data structures like
lists can hold any kind of object that you want. The exercises are
related to parsing columns of data in CSV files and concepts are later reused in
Section 3.2.
Timing: Ideally, you want to be done with section 2 on the first day.
However, it is common to finish with section 2.5 or 2.6. So, don't
panic if you feel that you're a bit behind.
## 3. Program Organization
The main goal of this section is to introduce more details about
functions and to encourage students to use them. The section builds
from functions into modules and script writing.
Section 3.1 is about going from simple “scripting” to functions.
Students should be discouraged from writing disorganized “scripts.”
Instead, code should at least be modularized into functions. It makes
the code easier to understand, it makes it easier to make changes
later, and it actually runs a little bit faster. Functions are good.
Section 3.2 is probably the most advanced set of exercises in the
whole course. It has students write a general purpose utility
function for parsing column-oriented data. However, it makes heavy
use of list comprehensions as well as lists of functions (e.g.,
functions as first-class objects). You will probably need to guide
people through every single step of this code, showing how it works in
great detail. The payoff is huge however---you can show people a
short general purpose function that does something amazingly powerful
and which would be virtually impossible to write in C, C++, or Java
without having a *LOT* of very complicated code. There are a lot of
possible design/discussion avenues for this code. Use your
imagination.
Section 3.3 adds error handling to the function created in Section 3.2
This is a good time to talk about exception handling generally.
Definitely talk about the dangers of catching all exceptions. This
might be a good time to talk about the “Errors should never pass
silently” item on the “Zen of Python.”
*Note: Before Exercise 3.4, make sure students get fully working versions of report.py, pcost.py, and fileparse.py. Copy from Solutions folder if needed *
Section 3.4 Introduces module imports. The file written in Section
3.2-3.3 is used to simplify code in Section 3.1. Be aware that you
may need to help students fix issues with IDLE, sys.path, and other