The outline covers assessment weighting, learning
outcomes and policies; the calendar is the same schedule shown below, as a
printable PDF. The exit ticket template is the slip handed out in
class — print your own if you need a spare. PyLite runs Python right in
your browser — nothing to install; handy for finger exercises on a lab
machine that doesn't have Thonny.
Course calendar
27 lectures · 15 weeks
slides opens a PDF in a new tabstarter downloads a zipreadings click to expandpending not yet postedEA1 extra activity: practice, not graded
Getting Started. What computation is, algorithms as recipes, and the difference between syntax, static semantics and semantics. Short; read it all, and try the finger exercise at the end.
Guttag §2.1 (opening)
The Basic Elements of Python: a program is a sequence of statements, the shell, and what print does.
Guttag §2.1.1
Objects, Expressions, and Numerical Types: every value is an object with a type; int, float, bool and None; the type() function. Read up to Figure 2.1 — the operators are next lecture.
Guttag §2.1.3
Python IDE's. Skim only: the book uses Anaconda, we use Thonny, but the editor/shell/debugger picture is the same.
Operators on int and float, precedence and parentheses, == versus =, and the and / or / not operators. Try each example in the shell.
Guttag §2.1.2
Variables and Assignment: a variable is a name bound to an object (Figure 2.2), rebinding, choosing readable names, reserved words, comments, and multiple assignment (x, y = y, x). The core of this lecture.
Strings and Input: string literals, + and * on strings, len, indexing and slicing, and the input function. Read before class.
Guttag §2.3.1–2.3.2
Input in detail, and the digression on character encoding. The encoding part is background; skim it.
Guttag §5.5 (string methods)
Strings, Tuples, Ranges, and Lists — only the string methods table near the end (find, split, strip, …). We use these from now on; ignore the tuple/list parts until lecture 11.
Scoping: the three rules for name lookup and the stack-frame pictures (Figures 4.2 and 4.3). These are the environment diagrams we draw in class — read it twice.
Guttag §4.4
Global Variables. Why the book calls them 'a good way to make programs hard to understand'. Short, optional.
Stochastic Programs and Calculating Simple Probabilities: random.random, random.choice, and what 'the same program gives different answers' means. Read before class.
Guttag §14.1–14.2
Random Walks and the Drunkard's Walk: the simulation we build in class, minus the classes.
Guttag §16.4
Finding π by throwing darts. Short, and the best two-page argument for why simulation works.
Plotting Using PyLab: plot, title, labels, legends, figure, and saving to a file. The book uses pylab; matplotlib.pyplot is the same functions under the name we use.
Guttag §14.2 (plots)
The drunkard's-walk plots: a worked example of turning simulation output into a figure. Optional.
Recursion
lab
A4 due
25
Tue, 1 Dec
Testing, Debugging; Type Annotations
slidesfinger ex.readings
Guttag §6.1
Testing: black-box versus glass-box tests, boundary cases, and how to choose test inputs.
Guttag §6.2
Debugging: treat a bug as an experiment (§6.2.2), and what to do when the going gets tough (§6.2.3).
Using Table Lookup to Improve Performance: the same idea applied to a simulation, with timings.
Guttag §10.3
Hash Tables: why dictionary lookup is constant time, and therefore why 'use a dict' is so often the fix.
Guttag §9.3.7
Comparisons of Complexity Classes: pick the better algorithm before you tune the code. Re-read.
Simulation, Plotting
lab
—
27
Tue, 8 Dec
Course Review & Exam Preparation
slidesreadings
Guttag Appendix: Python 3.5 Quick Reference
The whole language we used, on four pages. Read it and mark anything you cannot explain — that is your revision list.
Guttag ch. 1–7, 9–10
Everything examinable is in these chapters. Re-do the finger exercises rather than re-reading the prose.
—
—
—
Thu, 10 Dec
Final Examination
—
exam paper
Slide decks and finger exercises are posted after each lecture; assignment
specs and starter kits when the assignment is released; quiz solutions
after the quiz; the midterm paper and its key after the midterm. Quiz
papers and the final are not distributed here. An extra
activity (EA) is practice: it is not graded and nothing is handed in.