Python - IDLE

IDLE (Integrated Development and Learning Environment) is an integrated development environment (IDE) for Python. The Python installer for Windows contains the IDLE module by default.

IDLE is not available by default in Python distributions for Linux. It needs to be installed using the respective package managers. Execute the following command to install IDLE on Ubuntu:

$ sudo apt-get install idle

IDLE can be used to execute a single statement just like Python Shell and also to create, modify, and execute Python scripts. IDLE provides a fully-featured text editor to create Python script that includes features like syntax highlighting, autocompletion, and smart indent. It also has a debugger with stepping and breakpoints features.

To start an IDLE interactive shell, search for the IDLE icon in the start menu and double click on it.

Python IDLE

This will open IDLE, where you can write and execute the Python scripts, as shown below.

Python IDLE

You can execute Python statements same as in Python Shell as shown below.

Python IDLE

To execute a Python script, create a new file by selecting File -> New File from the menu.

Enter multiple statements and save the file with extension .py using File -> Save. For example, save the following code as

Python Script in IDLE

Now, press F5 to run the script in the editor window. The IDLE shell will show the output.

Python Script Execution Result in IDLE

Thus, it is easy to write, test and run Python scripts in IDLE.

Learn about different open-source editors for Python in the next chapter.

Want to check how much you know Python?