Abstract
A tutorial for the Python programming language, release 2.7.
This publication is available in Web form and also as a PDF document. Please
forward any comments to tcc-doc@nmt.edu.
Table of Contents
def: Defining functionsclass SnailRun: A very small example
classThis document contains some tutorials for the Python programming language, as of Python version 2.7. These tutorials accompany the free Python classes taught by the New Mexico Tech Computer Center. Another good tutorial is at the Python website.
This tutorial makes heavy use of Python's conversational
mode. When you start Python in this way, you will see
an initial greeting message, followed by the prompt
“>>>”.
On a Windows machine, from the menu, select → → . You will see something like this:

For Linux or MacOS, from a shell prompt (such as
“$” for the bash shell), type:
python
You will see something like this:
$ python Python 2.7.1 (r271:86832, Apr 12 2011, 16:15:16) [GCC 4.6.0 20110331 (Red Hat 4.6.0-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
When you see the “>>>” prompt, you can type a Python expression, and
Python will show you the result of that expression. This
makes Python useful as a desk calculator. (That's why
we sometimes refer to conversational mode as
“calculator mode”.) For example:
>>> 1+1 2 >>>
Each section of this tutorial introduces a group of related Python features.