trainingtrains Logo

91-9990449935

 0120-4256464

How to execute python

There are three different ways of working in Python:

1) Interactive Mode:

You can enter python in the command prompt and start working with Python.

write python code

Press Enter key and the Command Prompt will appear like:

write python program

Now you can execute your Python commands.

Eg:

execute python in interactive mode

2) Script Mode:

Using Script Mode , you can write your Python code in a separate file using any editor of your Operating System.

How to execute python Script Mode

Save it by .py extension.

How to execute python Script Mode 2

Now open Command prompt and execute it by :

Script Mode execute python

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

3) Using IDE: (Integrated Development Environment)

You can execute your Python code using a Graphical User Interface (GUI).

All you need to do is:

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

Python Using IDE

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

1) Using Interactive mode:

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

Python Using IDE

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 your Python code here.

Python Using IDE

Click on file -> save as

Python Using IDE

Run then code by clicking on Run in the Menu bar.

Run -> Run Module

Result will be displayed on a new Python shell as:

Python Using IDE
Next TopicPython Variables