Python is a programming language. The language is made up of instructions that you put in a program in order to tell your computer what to do. For example to get it to print ‘Hello’ on the screen, you just write:
print “Hello”
That’s all there is to programming! You have to learn the available instructions and the required way of typing them into a program. Then you press the ‘run’ button and the computer does as it’s told.
Python is also the software that interprets your instructions into a form that the computer can understand. It is this software that you first have to download and install on your computer.
At the website http://www.python.org/download/ you will find downloads for both Windows and for Mac. The current version is 3.2.3 (April 2012).
After downloading, an icon will appear on your desktop. Double-click this to instal python, and if you’re operating system is Windows you’ll find a new folder ‘Python 25’ in your root directory and also in your Start|All Programs list. Click this latter folder, and you’ll find an icon called ‘Idle’ inside. Click on ‘Idle’ and python starts by putting a form called Python Shell on your screen.
On the Mac, installation of python puts a folder ‘Python for Mac’ in your Applications folder and this contains ‘Idle’. Click it to get the Python Shell.
If you type 2+2 in the Shell and press Enter, python displays 4. You can play such games. But better is to click File|New Window which will give you a form on which to write your first program. Type the two lines below, making sure you start at the left hand side:
print (‘hello’)
print (2+2)
and press the key F5 to run this little program. After you give a file name (test1.py will do), and press Enter, your program will run, and display the result of your commands in Python Shell, just as shown below. The Shell is where the output of a program is displayed:
The program code
print('hello')
prints the word 'hello' and then a carriage return so that the next item to be printed starts on a new line. If you want to printing something else later on the same line then the command must be altered to
print('hello',end="")
and the printed line will end without a carriage return. This terminology is new to Python v3 and is, in my opinion, much clumsier than previously (which I won't bother you with) but sometimes complexity is the price of progress.