Skip to main content
HomeAbout PythonLearn Python

Introduction to Python IDLE Tutorial

Learn what is Python IDLE (Integrated Development and Learning Environment) is, how you can install it, and leverage its various features for writing your Python programs.
May 2020  · 9 min read

I

f you are just getting started in Python and would like to learn more, take DataCamp's Introduction to Data Science in Python course.

python shell
Python IDLE

Introduction

IDLE stands for Integrated Development and Learning Environment. The story behind the name IDLE is similar to Python. Guido Van Rossum named Python after the British comedy group Monty Python while the name IDLE was chosen to pay tribute to Eric Idle, who was one of the Monty Python's founding members. IDLE comes bundled with the default implementation of the Python language since the 01.5.2b1 release. It is packaged as an optional part of the Python packaging with many Linux, Windows, and Mac distributions.

IDLE, as shown above, is a very simple and sophisticated IDE developed primarily for beginners, and because of its simplicity, it is highly considered and recommended for educational purposes. It offers a variety of features that you will look in detail along with examples later in this tutorial.

Some of the key features it offers are:

  • Python shell with syntax highlighting,

  • Multi-window text editor,

  • Code autocompletion,

  • Intelligent indenting,

  • Program animation and stepping which allows one line of code to run at a time helpful for debugging,

  • Persistent breakpoints,

  • Finally, Call stack visibility.

How to Install IDLE?

  • One way to install IDLE is to install Python from the officail Python website, as shown below.

    You can download the latest Python versions from this website for different operating systems like windows, Linux, and mac. It also provides you the docker images for Python, which you can directly use if you have a docker installed on your system.

How to Install IDLE

Let's install Python for the Windows operating system.

Installing Python on Windows OS

  • Since Python2 development has been stopped, let's install the latest Python version, i.e., 3.8.2.
Installing Python on Windows OS
  • Install the Windows x86 executable installer file depending on whether you have a 32-bit or 64-bit OS and run that file. Once you run the file, a window will open, as shown below. Make sure you select the install launcher for all users and add Python3.8 to Path along with the recommended installation.
Installing Python on Windows OS
  • Once the installation is complete, go to the start menu and type idle and click on the same. You should now be seeing the IDLE software on your system.

IDLE with Anaconda

IDLE can also be used through Anaconda. If you already have Anaconda installed on your system, just open the anaconda prompt from the start menu and type idle in the anaconda terminal, as shown below.

IDLE with Anaconda

Since IDLE comes packaged with Anaconda, you will need to download Anaconda from this website.

To learn how to install Anaconda, check out the documentation.

Well, now that you have the IDLE software installed on your respective systems, let's understand its features in detail.

Exploring IDLE Software Features

  • Remember that it is not advisable to write multiple lines of code that have functions/classes in the IDLE shell. In such cases, you can go to the File option of IDLE and click on New File.
Exploring IDLE Software Features
  • IDLE can be customized using the options present in the Format, Edit, and Options menu.

    • Modifying the font-size: Go to the Options menu and click configure idle.

      From this, you can choose any font face, font size, make the font bold and even calibrate the indentation width you like working with, as shown below.

      IDLE provides you this feature so that each and every person can work with a font size he/she is comfortable working with. A lot of times, your monitor screen size is small, and as a result, you need an IDE that can allow you to increase the font size. That's where IDLE can come into play and give a sense of relief to your eyes.

      Not just the font size and style, you can even adjust the indentation, as mentioned before, which is set to 4 spaces by default as per the PEP-8 coding guidelines.

Exploring IDLE Software Features
  • Writing your first code in IDLE

    You will write a small program in which you will import the NumPy library, define two arrays, and sum them up. Finally, you will run the code and see the output in the IDLE shell.

    To be able to import the NumPy library, make sure it is installed on your system. If not, just go to the command prompt and type pip install NumPy.

Writing your first code in IDLE

Call Stack Visibility

While writing the above code, you would notice a dialog box on the screen for both the print function and np.sum function. IDLE will give you the details as to what parameters can be passed to the np.sum function. This is one of the more important and less obvious features of IDLE, which shows the call stack in a verbose manner.

Call Stack Visibility

To run the above code, go to the run menu and click on the run module option or directly press F5. It should open the IDLE shell along with the output of your program.

Call Stack Visibility
Call Stack Visibility

Edit Menu in IDLE

The edit menu in IDLE has a lot of general features like:

  • undo,
  • redo,
  • find,
  • find in files,
  • replace,
  • go to the line,
  • show surrounding parenthesis

But one which makes it special is the show completions feature with which you can autocomplete your code. Imagine you are working on a large and complicated project which involves a lot of coding. You might end up spending a lot of time typing the code.

The show complete feature in IDLE helps you in saving typing time by trying to finish the code for you. The Python IDLE is capable of autocompleting only functions and classes. The autocompletion feature can be used by pressing either the tab key or ctrl+space, as shown below:

Edit Menu in IDLE

You already saw the Fonts/Tabs feature, now let's look at some more features in configure_idle under the options menu.

  • Highlights: Here, you can change the color of the code syntax according to your preference and not just that. You can also configure idle to work in dark mode or theme, which is a great feature to have, especially when you want to code for longer duration and give some relief to your eyes.

    By default, idle works in classic mode and can be tuned to work in a dark mode.

Edit Menu in IDLE

Idle in Dark Theme!

Idle in Dark Theme!
  • Keys: This feature lets you map different key presses to actions, also known as keyboard shortcuts. These are vital components to increase your overall productivity while using an IDE. You can either come up with your own keyboard shortcuts or use the default ones.

    As can be seen from the below figure, the keys are represented in the Action - Key format, which shows you the action that is performed when a specific key or keys are used. Though rarely used by developers, the keys feature in IDLE makes your life easier, especially when you want to write a lot of code in a quick manner.

Idle in Dark Theme!

Format Menu

Like other menu's, Format also has few useful features like indent region, dedent region, comment out a region, etc.

Let's look at the indent region. The indentation in Python is used to segregate a block of code, let's say you have written a code but missed giving indentations to it, the indent region feature could come to your rescue.

The ident region tab added 4 spaces to the selected lines of code, as shown below:

Format Menu



Similarly, the dedent region will help you in removing any unnecessary spaces from your code.

Writing a Palindrome Code in IDLE

A palindrome is a word, phrase, or sequence of numbers that read the same backward as forward.

For example, sequence 121, 151, etc.

Let's quickly write the Palindrome code in IDLE and check the output.

Writing a Palindrome Code in IDLE



Let's now save the above code and run it.

Writing a Palindrome Code in IDLE



From the above output, you can observe that in all four experiments, the program expected input from the user, and based on the input, the if-else conditions were executed.

Conclusion

Congratulations, you have made it to the end of this tutorial!

In this tutorial, you've learned about Python IDLE, how to install it, and various features associated with it. Since now you are familiar with IDLE's features and capabilities, it would be much easier for you to start using it.

Those of you who have just started to learn Python, IDLE would be the best development environment for you to get your hands dirty by starting to code in it.

If you are just getting started in Python and would like to learn more, take DataCamp's Introduction to Data Science in Python course.

Topics

Python Courses

Certification available

Course

Introduction to Python

4 hr
5.4M
Master the basics of data analysis with Python in just four hours. This online course will introduce the Python interface and explore popular packages.
See DetailsRight Arrow
Start Course
See MoreRight Arrow
Related

Mastering the Pandas .explode() Method: A Comprehensive Guide

Learn all you need to know about the pandas .explode() method, covering single and multiple columns, handling nested data, and common pitfalls with practical Python code examples.
Adel Nehme's photo

Adel Nehme

5 min

Python NaN: 4 Ways to Check for Missing Values in Python

Explore 4 ways to detect NaN values in Python, using NumPy and Pandas. Learn key differences between NaN and None to clean and analyze data efficiently.
Adel Nehme's photo

Adel Nehme

5 min

Seaborn Heatmaps: A Guide to Data Visualization

Learn how to create eye-catching Seaborn heatmaps
Joleen Bothma's photo

Joleen Bothma

9 min

Test-Driven Development in Python: A Beginner's Guide

Dive into test-driven development (TDD) with our comprehensive Python tutorial. Learn how to write robust tests before coding with practical examples.
Amina Edmunds's photo

Amina Edmunds

7 min

Exponents in Python: A Comprehensive Guide for Beginners

Master exponents in Python using various methods, from built-in functions to powerful libraries like NumPy, and leverage them in real-world scenarios to gain a deeper understanding.
Satyam Tripathi's photo

Satyam Tripathi

9 min

Python Linked Lists: Tutorial With Examples

Learn everything you need to know about linked lists: when to use them, their types, and implementation in Python.
Natassha Selvaraj's photo

Natassha Selvaraj

9 min

See MoreSee More