Python statements one by one.
Now that you have seen two methods for running a Python script, it’s time to look at how to create a
Python script. You have two methods to choose from here as well.
Using IDLE to Create a Python Script
Creating a Python script in IDLE is easy. You simply open the IDLE text editor window from the
IDLE interactive mode window by clicking Ctrl+N or by clicking the File menu and selecting New
Window. You see a new window open, with the word “Untitled” on the title bar. You are now in the
basic IDLE text editor. In this mode, when you type in your Python statements, they will not be
interpreted, and no output will be displayed.
In the basic IDLE text editor, type in the Python statements to create your script. When you are all
done, you save the statements to a file.
Did You Know: Editing in IDLE
You are not limited to only using the arrow keys and the Delete key for editing text
files. Take a look at all the options available in the Edit menu. You can undo an edit,
find words, copy and paste, and so on. The text editor in IDLE may be a basic text
editor, but it does offer you a lot of help.
To save the Python script to a file, start by pressing Ctrl+S or by clicking on the File menu and
selecting Save. A Save As window appears, as shown in Figure 3.11. Navigate to the directory
where you want the file to be stored. Type in the name of the file and click the Save button.
FIGURE 3.11 Saving a Python script from IDLE text editor.
Did You Know: The “py” in Python Scripts