Python is a general purpose interpreted language which has several major advantages for math and science users. Python is freely available, is pre-installed on most UNIX/OSX/Linux systems, and has features (packages, operator overloading) which lend themselves to the mathematics user. It is an interpreted language, so it can be used like a calculator for simple computations.
Python is free and can be easily installed on most computer systems. Downloads
are available from the Python home page [http://www.python.org].
Python is pre-installed on UNIX/OSX/Linux systems. It is thus available in computer labs,
on remotely accessible servers and on home machines.
python.
http://www.python.org].
A basic Python command line interpreter is available using the SKULPT Python-to-JavaScript library.
At the Python command prompt (which usually looks something like >>>)
type the command to be run, and then press the Return key to have Python run the
command. As a simple example, if you want to add two integers type:
3 + 12
Intermediate values can be saved by giving them a name and assigning them a value with the
= operator. If the following two commands are run the second output will be the
value 4:
thesum = 3 + 15
thesum - 14
Python is very careful about exact integer values. Thus the quotient 12/5
returns a value of 2. If a decimal (aka floating point) value is wanted one of the operands
can be written in that form, so 12.0/5 returns a value of 2.3999 (which is
approximately 2.4).
When you are done with Python, hold down the Control key and type d.
The most authoritative and up-to date source for Python documentation is on the Python home page at [http://docs.python.org/]. Particularly useful for the beginner are the various tutorials listed at [http://wiki.python.org/moin/BeginnersGuide].
The basic Python commands are documented at [http://docs.python.org/library/functions.html].
A very thorough reference to the commands, functions and options of Python is at [http://rgruet.free.fr/PQR26/PQR2.6.html]
When working with Python you can move in a line using the usual left and right arrow keys. Earlier commands can be recalled with the up arrow key. If you are familiar with the simple Emacs commands you can use them as well.
If a file contains python commands they can be executed either from the UNIX command line or from within a Python session:
% python myfile.py - Will run the python code in the file myfile.py from the UNIX command line.
>>> execfile("myfile.py") - Will run the python code in the file myfile.py from the Python command line.
A more flexible way to import Python commands into a session is with the import command.