This lesson is about creating a Python program. A program is a series of coding statements saved in a file. Rather than entering individual statements into an interactive shell such as that provided by IDLE, the objective is to enter statements into a file and execute them as a unit.
Creating a Python File
In IDLE, select File/New from the menu, or use the shortcut combination CTRL-N. Both will open a new, blank IDLE editor window.
The default IDLE window is empty. This displays a command prompt (>>>) to enter commands.
The IDLE File menu allows you to create a new file or open an existing file. For a new file, the editor is empty.
Enter your program in the editor window. It is okay to enter a few lines at a time before testing it.
Save the file using the File menu or CTRL-S.
To run the program, using the menu or CTRL-F5.
The program will execute or run in the main IDLE window. Do not confuse this with your program in the editor.
Test the program to see that it runs as expected. Most assignments will provide details on how to test the program (how the Instructor will test it for grading). If that information is available, make sure your program produces the same results as the testing guidelines. Test multiple times!
If you make changes to the program, re-save it (using the menu or CTRL-F5) before running it again.
Always run the program to test it before submitting the file for an assignment. The editor saves the program with a .py extension. Submit the .py file for the assignment. (Do not copy/paste IDLE window code or results)