We have shown two ways of executing Python, genuinely we have used IDLE for executing python. however there are three ways for executing and python program, which we are going to discuss here,

How to execute python

1) Interactive Mode

Python provides Interactive Shell to execute code immediately and produce output instantly. To get into this shell, write python in the command prompt and start working with Python.


Press Enter key and the Command Prompt will appear like:

Now we can execute our Python commands.

executing python


how to execute python


2) Script Mode

Using Script Mode, we can write our Python code in a separate file of any editor(Example notepad, notepad++ or which you like) in our Operating System.


executing python in notepad


Save it by .py extension.



Now open Command prompt and execute it by :

executing python in notepad 1

You can also see the output in this screenshot


NOTE: Path in the command prompt should be location of saved file.where you have saved your file. In the above case file should be saved at desktop.


3) Using IDE (Integrated Development Environment)

We can execute our Python code using a Graphical User Interface (GUI).

All you need to do is:

Click on Start button -> All Programs -> Python -> IDLE(Python GUI)



We can use both Interactive as well as Script mode in IDE.

1) Using Interactive mode:

Execute our Python code on the Python prompt and it will display result simultaneously.


2) Using Script Mode:

i) Click on Start button -> All Programs -> Python -> IDLE(Python GUI)

ii) Python Shell will be opened. Now click on File -> New Window.

A new Editor will be opened. Write our Python code and then.


Click on file -> save as


Run code by clicking on Run in the Menu bar.

Run -> Run Module

Result will be displayed on a new Python shell.

Otherwise we can also use pycharm as IDE for python,and we have shown earlier also how to use and install Pycharm IDE,if you want to learn again click here