< Prev  |  Home  |  Next >

Running a Python Program

I’m guessing you’ve got a computer near your face at the moment? If so, you’ve nearly got everything you need to start writing Python programs.

To get Python, go to The Python Website and click ‘Download’ to get the latest version for your system. When this was written, version 3.3 was the latest version.

Once you’ve installed Python, the bit we’re interested in is the IDLE Python GUI. GUI stands for Graphical User Interface. Open this up now, by typing ‘IDLE’ into the start bar, or by finding it in your list of installed programs. This is how it looks in Windows 7:

The IDLE icon

Click on the icon, and you’ll find yourself staring at the shell. In the shell, you can type in commands one at a time. For example, if you type:

into the shell. See that? Can you believe it? Your computer just asked you how you are. I bet you never ask your computer how it is.

The shell

Using the shell is OK for short programs that you don’t need to save or share with other people, but if you’ve spent time making an amazing game (which we will be doing) you’ll want to save it and share it. To do this, open a new window, by clicking File > New Window, and type the same ‘print’ command into the empty box that appears. Click File > Save, and call it something.py. The .py extension is important, as it tells IDLE that we are writing a python program.

Saving a Python file

Once the file has been saved, click Run > Run Module, and see it execute in the shell.

Running a Python program

So there we have it. A Python program. All that remains now is the small matter of teaching you some Python. Step this way, please.

< Prev  |  Home  |  Next >