Python Interpreter

Python code is directly interpreted. There is no need to compile the code. Python Interpreter which is written in C language, interprets the program directly in machine readable format for actual execution by the CPU.

The UTF-8 encoding is the default for the Python source file.

In Windows, Python interpreter is installed at 'C:\Python 27' or at the directory you choose during installation.


Run Python Program

These are the different ways to run the Python program-


Launch Python Shell

1. Go to start-> All apps, click on the Python folder and launch the Python (command line).

python interpreter

Now, type this code in the command prompt and press enter. Python prompts with '>>>'. When you see the '>>>' prompt, you can enter the Python statement.

>>> print("First Python Program")
First Python Program
>>> 

python interpreter

This is an excellent facility for learning Python and for trying small snippets of code.


Launch Python IDLE

2. Go to start -> All apps, click on the Python folder and click on IDLE icon.

python interpreter

On the opened IDLE shell, type this code and press enter.

>>> print("First Python Program")
First Python Program
>>> 
python interpreter

IDLE is a graphical integrated development environment for Python, it contains a Python shell.


Create Python File

3. Open Python IDLE, click File->New File and write this code.

>>> print("First Python Program")
First Python Program
>>> 

and save this file as 'first_program.py' and then run this code on click 'Run->Run Module'. You will see the output as in the below screenshot.

python interpreter

IDLE is a python integrated development environment or editor which is available for Window, Linux, Mac and OSX.

This is a good practice to write the code in an editor, save the code in a file with py extension and then execute the program.


Launch Python on Linux or MacOS

To launch Python on Linux or MacOS, simply type 'python' from a shell prompt -

python

Exit Python Program

To exit from Python program, simply press CTRL-D.






Read more articles


General Knowledge



Learn Popular Language