Python IDLE, Shell and Command Prompt [Walk-through]

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:

How to install Python Interpreter?
  1. Visit Python download page
  2. Download latest version of Python executable file (python3x.exe)
  3. Navigate to downloaded .exe file and run
  4. 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 IDLE shell app

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.

Python Shell Window

Python shell is an awesome environment to work on simple commands. You can write command and just press enter to see the instant result. It also useful when you are not sure or want to check specific command or syntax.
				>>> 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

Python shell app

2. Python Command Prompt: type “command prompt” in search bar and open cmd then type command “python” to trigger python interpreter. 

Python Command Prompt launch

3. Python IDLE: type “IDLE” in your search bar and open IDLE shell window.

Python IDLE

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.

How to Open Python IDLE Editor?

As mentioned earlier, IDLE by default opens the shell window, if you want to open editor window then follow these steps.

  1. Open IDLE shell window (which is default one)
  2. Go to “File”>> “New file
  3. New editor window will open automatically.
  4. Write your program and save it with .py extension.
Python IDLE New File

If you have python program saved in your computer, then you can simply right click on that file and say, Edit with IDLE

Python IDLE Shell and Command Prompt

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.

run Python code in IDLE

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”

Configure Python IDLE

Command Prompt

How to run python code in 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
			
Python IDLE Command Prompt

Leave a Comment