Python IDLE – Integrated Development & Learning Environment
Python IDLE – It is an Integrated Development Environment (IDE) for python, packaged as an optional part of the python packaging. IDLE is completely written in python and the Tkinter GUI toolkit (wrapper functions for Tcl/Tk).
IDLE is intended to be simple IDE and suitable for beginners, especially in the education environment where people want to play with the Python!
Python IDLE Key Features
- Multi-window text editor
- Syntax highlighting
- Auto-completion
- Smart Indent
- Python shell with syntax highlighting
- Integrated debugger with stepping
- Persistent breakpoints
- Call stack visibility
Python Interpreter
I have python 3.8 version installed on my computer. If you also have python installed on your machine, then you will find the python executable file python.exe located at your installation directory.
…//python38/python.exe
Do not have python Installed?
No worries!!
Follow these simple steps:
- Visit Python download page
- Download latest version of Python executable file (python3x.exe)
- Navigate to downloaded .exe file and run
- Select Installation path and click Next & Finish
To launch the python interpreter, navigate to python.exe file and execute it.
An alternative and easy way to launch interpreter would be simply search “Python” or “IDLE” from your home window and launch it. You can run your python command from its interpreter window directly.
Python Shell & Editor Window
IDLE has two main window types- the Shell window and the Editor window. Shell window is a default one where you can fire python commands and see the output in the same window – just after your command.
There is limitation to use Shell window, you cannot write multiple lines of code at one go and execute it.
It only allows you to write single line of code and execute it.
>>> 10+40
50
>>> print(“Bye Byee……”)
Bye Byee……
>>>
Python shell can be launched in three ways-
1. Python Shell (App): type “python 3.8” in search bar and open python shell
2. Python Command Prompt: type “command prompt” in search bar and open cmd then type command “python” to trigger python interpreter.
3. Python IDLE: type “IDLE” in your search bar and open IDLE shell window.
PS: Python IDLE is very famous and mostly used by hard core python programmers!
Python IDLE & it’s Editor
Python IDLE looks very similar to python shell app or command prompt but it has many more functionalities. It comes with very powerful IDLE Editor tool!
Python IDLE editor is a very easy to use and convenient for many people because of its GUI, designed as your simple Notepad file.
As mentioned earlier, IDLE by default opens the shell window, if you want to open editor window then follow these steps.
- Open IDLE shell window (which is default one)
- Go to “File”>> “New file”
- New editor window will open automatically.
- Write your program and save it with .py extension.
If you have python program saved in your computer, then you can simply right click on that file and say, Edit with IDLE
How to run Python code in IDLE?
Once you have your program ready, save your program in any directory and execute the program from top bar of window.
You can see many options available on top of window as such –
File, Edit, Format, Run, Options, Windows, and Help.
You can run your program by selecting “Run” >> “Run Module” or just press “F5”. The output of your program will appear in the background “Python 3.8 Shell” window.
If your shell window is not open at that time, then the moment you click on “run module” or press- F5 shell window will automatically open with you program output.
Configure IDLE Editor
You can configure your code environment by setting up your favourite font size, colour adjustment and many more. All these settings you will find it in IDLE editor – “Options>> Configure IDLE”
Command Prompt
There is one more way to run your python code and that is through command prompt window.
If you have python installed on your machine (windows, Linux/Unix or Mac OS) you can run python interpreter through Command prompt. Go to Home window, search “cmd” and open the command prompt window.
Use Command Prompt as a shell
Type “python” to start python interpreter and enter into python shell environment where you can write commands and see the output instantly similar to shell window we saw in previous section.
The moment you enter “python” on cmd, it also prints python interpreter details before enter into shell mode which shows installed python version details.
Microsoft Windows [Version xxxxxxxx]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\MayurJadhav>python
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29)
[MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Run Python code directly from command prompt
There is also possibility to run whole python program from command prompt without entering shell mode. For this, first you need to write your code using any application like notepad and save it with .py extension.
You can invoke python interpreter using py or python command followed by python code file(with complete file location).
Syntax:
py /file_path/filename.py
python /file_path/filename.py
ADDITIONAL RESOURCES:
- How to define and call functions in Python?
- Control statements in Python: break, continue, pass keywords
- If-Else Statement in Python
- For loop and While loop in Python
- Python IDLE, Shell and Command Prompt (Guide)
- Exception handling in Python
- Python Variables, data types, and values
- Python function arguments
- Python interactive mode and script mode programming
- How To Install and Download Python Anaconda?
- Python Raise Keyword
- What is Python? Why it is most loved programming language?
- Write your first Python program!
- Zen of Python and Anti-Zen of Python
- Best Python books to read and learn!