Table of Contents
def: Defining functions
This document contains some tutorials for the Python programming language. 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 TCC workstation in Windows, from themenu, select → → . You will see something like this:
For Linux or MacOS, from a shell prompt, type:
You will see something like this:
-bash-3.1$ python Python 2.4.2 (#1, Feb 12 2006, 03:59:46) [GCC 4.1.0 20060210 (Red Hat 4.1.0-0.24)] 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. For example:
>>> 1+1 2 >>>
Each section of this tutorial introduces a group of related Python features.