Python

Programmers call Python a high level programming language, meaning that its elements and structure resemble natural human language (e.g. English) more than they resemble the machine language that computer processors understand. It is a higher level language than C++ therfore it is easier to program than C++. A Dutch computer programmer named Guido van Rossum created Python in the early 1990's. He named it after the British comedy troupe Monty Python, not after the reptile species. The Python homepage is www.python.org.

Python programs usually run from an interpreter. An interpreter is software that reads source and then executes it. That means you write the program in a "script" with the .py extension and then the Python interpreter makes it run. Most modern Linux, Unix, and BSD distribution have Python installed as default but MS Windows doesn't.

Python has a development environment called IDLE which provides an easy way to write and test python progtrams. You will have Idle installed on Windows XP when you download and install python-2.5.1.msi. FreeBSD users can install it at the ports collection in the /usr/ports/x11-toolkits/py-tkinter directory by running the command make install. After it is installed open it from a terminal window by typing idle.

When you have IDLE installed, open it and you should see a Python window with a prompt that looks like the following:

	IDLE 1.1.3
	>>>

I follow the computer programmer tradition of beginning the learning of a computer language by writing a program that prints "Hello world!" to the screen. Let's begin now. At the IDLE window prompt type print "Hello World!" and press enter. The IDLE window now contains the following:

	IDLE 1.1.3
	>>>print "Hello World!"
	Hello World!
	>>>

The Python interpreter followed the print command and and displayed whatever text appeared between the quotation marks on the next line. A line of code like this that has a command and some data is called a statement. Python interpreted the statement and displayed the result on the next line. Running Python this way is called interactive mode and it is a good way to testing code a single statement at a time. However if you want to run more complex code or you just want to save your code, you will need to write Python scripts. Here is how to create a Python script:

1. From the IDLE window's File menu select New Window.

2. In the new window write your code as follows:

	#Hello world program (Python ignores lines starting with #)
	print "Hello World!"
	


3. From the New Window's File menu select Save As... and save the program anywhere you wish with whatever name you like just so long as the name has the extension .py.

4. You may run the program in either of two ways:
 - From the Run menu of the New Window select run.
 - Run the program directly from the directory where you saved it.

5. Windows users will see a blur if they run this program directly from the folder were it is saved because it exits as soon as it has run. To remedy this, add the following line to the end of the program. This line of code tells the program to wait for input from the keyboard:

	 raw_input("\n\nPress the enter key to exit.")