Python Tutorial

« Previous | Next »

The Python Tutorial is an optional part of 6.01. Students with Python programming experience can skip this section and proceed to Unit 1.

Learning Python

You should be familiar with the basics of programming before starting 6.01. These exercises are to make sure that you have enough familiarity with programming and, in particular, Python programming.

This is not meant to be a stand-alone introduction to computer programming. Rather, it’s a way for someone with some previous exposure to programming to get some practice and to learn the basics of Python. The goal of the exercises is to give you practice with Python concepts and to help diagnose your level of programming ability.

Some of the later problem sets are much longer than the earlier ones, because we need the concepts in the earlier sections before we can really write many interesting programs. So, don’t be misled by the short length of the early problem sets.

Python Documentation

Each section of this tutorial includes notes on Python written for 6.01, as well as pointers to chapters of Think Python: How to Think Like a Computer Scientist.

Another useful reference for Python details is the official Python Tutorial.


For 6.01, we’ll be using Python 2.6.x and the IDLE environment for editing and executing Python code (although some people may prefer to use Emacs for editing code). See the Software and Tools page for more details.

Tutorial Sections

Types, values, expressions; variables and binding

Functions and scope

Using if, else, and while

Quadratic roots

Loops and list comprehensions

Arrays as lists of lists

Association lists

« Previous | Next »

Learning Resource Types
theaters Lecture Videos
theaters Recitation Videos
assignment Problem Sets
grading Exams with Solutions
notes Lecture Notes
menu_book Online Textbook
co_present Instructor Insights