Hello IDLE

Published

2022-11-21

Hello World! using IDLE

  1. Launch IDLE

  2. The default view in IDLE is a window for Python shell, so to create a new Python file, you’ll need to use the IDLE menu.

  3. Select “New File” from the “File” menu.

Figure 1: Hello World in IDLE (1). Note to Windows users: The IDLE menu may be slightly different, but the steps you need to take are the same. Create a new file.

This will open a new editor window, so you should see something like this:

Figure 2: Hello World in IDLE (2)
  1. In that window, enter the following Python code:
print('Hello World!')

followed by a single return/enter. Make sure you enclose Hello World! within quotation marks. Make sure there’s an open and closing parenthesis.

Your IDLE editor window should look like this.

Figure 3: Hello World in IDLE (3)
  1. Now save your file. Select File | Save As… from the IDLE menu.
Figure 4: Hello World in IDLE (4)
  1. When the dialog box opens, enter the file name hello_world.py, and make a note of the location where your file will be saved (you may change this location if you like). Click “Save”.
Figure 5: Hello World in IDLE (5)

Notice that we gave the file a name in all lower-case letters, with an underscore between words, and a .py extension. This is the convention in Python. Other languages may differ, but this is how we name Python files. All the programs you write for this course should follow this convention.

  1. Now your file is saved. To run your file, select “Run | Run Module…” from the IDLE menu.
Figure 6: Hello World in IDLE (6)

When your program runs, IDLE should bring the shell window to the front. The result should look like this.

Figure 7: Hello World in IDLE (7)

That’s it. You’ve written and run your first Python program in IDLE. Welcome to the club!

Original author: Clayton Cafiero < [given name] DOT [surname] AT uvm DOT edu >

This material is for free use under either the GNU Free Documentation License or the Creative Commons Attribution-ShareAlike 3.0 United States License (take your pick).