Updated: Monday 27th February 2023, 14:13 PT

How to run Python programs

 using the IDLE editor

Which version of Python should you install?

Example Python 2 Programs (HTML format)

Example Python 2 Programs (text format)

Example Python 3 Programs (text format)

Python Programming Resources

Python Programming Hint Sheet


Follow these instructions to write and run a simple Python program using the IDLE editor:


1.  Start IDLE. You will then see a window entitled "Python Shell" ...


Python Shell Window in IDLE




2.  From the Python Shell window, select New Window from the File menu.

3.  You will see a window entitled "Untitled"



Python IDLE Untitled Window



4.  From the File menu, select Save As, 
     and select a folder to save your Python program file.

Python IDLE Save As Window



5.  Select a folder to save your file in.

6.  In the File name: text box, type: program1.py

7.  Then click on the Save button. 
     You will then see a blank editor window ready 
     for you to type in your Python program.




Blank IDLE Editor Window





8.  The following program statement will run under Python 2.x or Python 3.0 

    Type in the following text into this window 
    (make sure the word print is all in lower case):

     print ("Hello World")

     If you're running Python 2.x, the text will automatically change colour to look like this:

     print("Hello World")

     If you're running Python 3.0.x, the text will automatically change colour to look like this:

     print("Hello World")




9.  To run this program, select Run Module from the Run menu.


     You should see a reminder to save the Source (your program). 
     Click on OK to save.

     Then you will see your program running in a Python Shell window.

IDLE Run Module Window




10.  Close all Python windows to quit Python.






IMPORTANT: 



To open your Python file again, 
locate the file in the folder, 
click once on the file name it to highlight it, 
then right-click on the mouse to see the options shown in
the screen below, and select Edit with IDLE 
to open the editor window. 


IDLE Window



From the editor window (the window with the program's name in the title bar),
select Run Module from the Run menu to 
see the program run in the Python Shell window.


****************************************************************
    To close a Python Shell or IDLE editor window
     Select Close from the File menu. 
****************************************************************
    To open and run an existing program file
     Select Open from the File menu.
****************************************************************
    Getting Help on IDLE
     Select IDLE Help from the Help menu
****************************************************************
    Getting Help on Python
     You select Python Docs from the Help menu or press keyboard key F1.
     The path for Python 3.0 is not correct - IDLE currently searches for documents here:
     http://docs.python.org/dev/3.0/ 
     when the Python 3 documentation is actually located here: https://docs.python.org/3.0/ 
Documentation for all versions of Python can be found here: https://docs.python.org
**************************************************************** To exit the Python Shell or IDLE editor Select Exit from the File menu. **************************************************************** Which version of Python should you install?
Example Python 2 Programs (HTML format)
Example Python 2 Programs (text format)
Example Python 3 Programs (text format)
Python Programming Resources
Python Programming Hint Sheet
Search all coding topics: Search

www.annedawson.net