Getting Started with Python in IDLE

Large portions of the text on this page were written by Michael A. Covington several years ago.  I have borrowed his material but updated it for the changes in Python and for use in our class.

IDLE ("Interactive DeveLopment Environment") is a simple, text editor/environment for developing Python programs ("scripts") under Windows and other operating systems.  


Interactive - You can interact with IDLE; you do something, the computer responds to it, you do something else, the computer responds to it, and so on. You do not simply put in your entire program and press one button.

Development - It's for developing Python programs.

Environment - It's an environment for you to work in. That is, a variety of tools for editing, checking, and running programs are all provided together.

Obtaining IDLE

IDLE comes with the version of Python distributed by and can (at present) be downloaded from

You should select python version 3. (or higher if it exists) and the version for your operating system.  For most of you this is the first link.  If you have a 64 bit computer you should use the second link. 

Starting IDLE

To start IDLE, pick it from under Python 3.2 in your Start Menu:

When it starts up, you'll see its main window, the "Python Shell":

What is this warning about firewall software?

Because IDLE was originally developed under UNIX, its various components (such as multiple windows running at the same time) sometimes communicate as if they were using a network. Even though everything is on a single computer, some security software will notice the abnormal activity and complain about it.

You can type Python statements and expressions for immediate execution or evaluation just the way your textbook indicates:

Notice the color code. The colors can be very helpful in helping you recognize when you have misspelled a keyword or left out a quotation mark.


Shell - The outermost layer of an operating system or piece of software that communicates interactively with the user. Originally, the "shell" was the part of UNIX or DOS that accepted commands typed by the user. Similar components of other software packages are sometimes called shells. The term is not widely used.

Expression - Something that describes a computation that gives a value. For example, 2+3 is an expression that can be evaluated to give 5, and (2+3)*4 is an expression with another expression inside it.

Evaluate - To determine the value of an expression.

Statement - Something that describes an action to be performed by the computer. For example, print("Hello") is a statement that tells the Python system to output Hello.

Execute - To do what a statement, command, or program says to do.

Writing a program (a script)

Python programs are called scripts because they are executed immediately, one line at a time. The computer does not translate them into something else first. (Contrast this with the way C programs are translated into .exe files and then the .exe files are executed.)

To write a program, choose File, New Window. An editing window pops up:

Type the previous program in the editing window, and save it (File, Save As...). Use "" as the name.

Caution: You must give the script a name ending in .py - this is not done automatically.

Hint for the perplexed:
If Windows does not show you the .py ending, or any of the other endings on your file names, then:
        - Open any folder.
        - Under Tools, Folder Options, View, uncheck "Hide file extensions...".
Then you'll be able to see the endings of file names as you browse.


Running your program

To run your program, choose Run, Run Module, or just press F5:

When you do this, the Python shell window will come to the front and your program will run in it:

Modifying your program and running it again

Now go back to the editing window, make the following small change:

 Hit F5 again. You'll get this cryptic message:

Source must be saved means "Your program must be saved." It is called source code because it is code written by a human being, not code generated by a computer. All computer programs, as written by humans, are called source code. Since Python programs are not normally translated into anything else before execution, the term "source code" is rarely used with Python. The astute reader will therefore realize that this editing window was originally used for languages other than Python, and it's giving away its origin.

As soon as you let IDLE save your program, it runs again in the Python shell:

Note that every time you start afresh, ====RESTART==== appears in the shell window. This helps you distinguish the latest run of your program from the previous one.