Once you open IDLE, the first thing you see is the “IDLE Shell” window, as shown in Figure 1.

Figure 1 The IDLE Shell

Notice: To open IDLE on Linux, type into the terminal “idle” or “idle3” without the double quotes.

IDLE Shell is an environment where you can type statements that are immediately executed. For example, if you type 7 + 3 and hit the “Enter ⤶” key, the IDLE Shell will directly display the result of this addition.

However, you must not write a Python program within the “IDLE Shell” window. To write a Python program, create a new Python file (known as a Python “module”). From IDLE Shell’s main menu select “File → New File” as shown in Figure 2.

Figure 2 Creating a new Python file (module) from within IDLE Shell

Notice: In simple terms, a “module” is a file containing Python code. Its filename is the module name followed by the .py file extension.

A new window opens, as shown in Figure 3. This is a new empty module where you will write your Python programs!

Figure 3 A new empty Python module

You have just seen how to create a new Python module. In the recently created window “untitled”, type the following (terrifying, and quite horrifying!) Python program.

print("Hello World")

Now let’s try to execute the program! From the main menu, select “Run → Run Module” as shown in Figure 4, or hit the F5 key.

Figure 4 Executing your first Python program

IDLE prompts you to save the source code. Click on the “OK” button, select a folder and a filename for your first program, and click on the “Save” button. The Python program is saved, executed, and then the output is displayed in the IDLE Shell window, as shown in Figure 5.

Figure 5 Viewing the results of the executed program in the IDLE Shell window

Congratulations! You have just written and executed your first Python program!

Now let’s write another Python program, one that prompts the user to enter their name. Type the following Python program and hit F5 to execute the file.

name = input("Enter your name: ")
print("Hello", name)
print("Have a nice day!")

Remember! You can execute a program by selecting “Run → Run Module” from the main menu, or by hitting the F5 key.

Once you execute the program, the message “Enter your name: ” without the double quotes is displayed in the IDLE Shell window. The program waits for you to enter your name, as shown in Figure 6.

Figure 6 Viewing a prompt in the IDLE Shell window

Type your name and hit the “Enter ⤶” key. Once you do that, your computer continues to execute the rest of the statements. When execution finishes, the final output is as shown in Figure 7.

Figure 7 Responding to the prompt in the IDLE Shell window