A Gentle Introduction to Programming Using Python

Course Description

This course will provide a gentle introduction to programming using Python™ for highly motivated students with little or no prior experience in programming computers. The course will focus on planning and organizing programs, as well as the grammar of the Python programming language. Lectures will be interactive featuring in-class exercises with lots of support from the course staff.
This course is offered during the Independent Activities Period (IAP), which is a special 4-week term at MIT that runs from the first week of January until the end of the month.

Lecture Notes

Notes and Worksheets

The session 1 notes (PDF) include the syllabus, some administrivia and an introductory tutorial to Python.
Exam 1 (Session 5) covered everything through class 3: variables, types, operators, functions, conditionals and loops. The solutions double as notes for sessions 1 through 3. (PDF)
The session 6 homework (PDF) doubles as notes for classes 4 through 6.
The optional session 7 homework (PDF) serves as useful practice with lists.
The session 8 notes (PDF) cover dictionaries and their usage.
The session 9 worksheet (PDF) reviews common errors and good programming practices.


Handout 1 (PDF) reviewed while loops and the basics of for loops.
Handout 2 (PDF) was a heavy review before the midterm, covering functions, lists, for loops and tuples.
Handout 3 (PDF) reviewed objects.
Handout 4 (PDF) reviewed dictionaries and gave guidance on part 1 of the Web indexer lab.
Handout 5 (PDF) was a walkthrough for part 2 of the Web indexer lab, and covered compound dictionaries.

Labs and Solutions

Lab 3 covered control flow with if-elif-else statements.
Lab 4 covered control flow with while statements.
login.py (PY)
nims1.py (PY)
nims2.py (PY)
Lab 5 covered the use of lists in storing a dynamic number of values.
sorting.py (PY)
reportcard.py (PY)
Lab 6 covered the use of tuples instead of lists and their similarity with strings.
collision.py (PY)
piglatin.py (PY)
Lab 7 was a walkthrough tutorial that introduced the idea of objects as opposed to primitive types like ints and floats. By exploring concepts like primitives (e.g. numbers) versus references to objects (e.g. lists), mutability versus immutability, and the effects of scope on objects, we now better understand how to use objects correctly.


1. Some commands will not produce the expected results when performed on the shell. Instead, run the commands from a file. I'm not sure why this is.
2. I was under the impression that Python aliases tuples automatically. It turns out this is not the case. In other words:
a = (1, 2, 3)
b = (1, 2, 3)
print a is b
However, you can still alias by saying b = a. Strings are still automatically aliased.
Lab 8 covered the use of member functions in various objects.
genetic.py (PY)
Lab 9 covered the use and syntax of dictionaries. The bulk of the lab was to explore one common use of dictionaries as indexes, in this case, for searching the Web.
namesages.py (PY)
websearch1.py (PY)
webindexer1.py (PY)
htmltext.py (PY)
smallsites.txt (TXT)
mitsites20.txt (TXT)
mitsites50.txt (TXT)
localsites.zip (ZIP)
namesages_soln.py (PY)
webindexer1_soln.py (PY)
Lab 10 covered a more advanced use of dictionaries. The bulk of the lab was to improve the web indexer we built in the previous lab.
inventory.py (PY)
websearch2.py (PY)
webindexer2.py (PY)
inventory_soln.py (PY)
webindexer2_soln.py (PY)

No comments: