IDLE is a code editor and IDE (Interactive Development Environment) that comes with Python. It can be used to enter and run commands in the Python interpreter, and to create Python program files.
It is not required to use IDLE for this course. It is one IDE you may use for coding assignments.
This article demonstrates how to create and run a Python program file. Additional articles can be found on the Internet to learn more about using IDLE; here are two examples:
- https://realpython.com/python-idle/ (MAC)
- https://www.tutorialsteacher.com/python/python-idle (Windows)
While IDLE can be used to enter and execute commands in the Python interpreter, the focus here is on using IDLE to create program files that will run in Python.
Creating a Python File
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)