1. PYTHON
INTERPRETER
IN THIS ARTICLE, WE WILL LEARN ABOUT THE PYTHON INTERPRETER, AND HOW IT WORKS.
AND ALSO GET INTRODUCED TO ITS ENVIRONMENT BY CODING.
pythongeeks.org
2. An Interpreter is a program that converts the code a developer writes into an
intermediate language, called the byte code. It converts the code line by line, one at a
time. It translates till the end and stops at that line where an error occurs, if any,
making the debugging process easy.
Python and Java are two examples of interpreted programming languages.
WHAT IS AN INTERPRETER?
3. WHAT HAPPENS WHEN YOU RUN PYTHON CODE?
On running a Python code, say a simple program that prints “Hello, World!”, then the following steps
happen:
1. The program gets converted into an intermediate code, called bytecode. This is also binary but is not
understood by the processor.
2. Python Interpreter, stored in the memory as a collection of instructions in binary form, does the above
conversion. These instructions can be thought of as a combination of a compiler and a Python Virtual
Machine (PVM).
3. The compiler converts the source code, the “Hello, World!” program, into the byte code, which is
platform-independent and understood by the PVM.
4. PVM reads the byte code and executes it on the hardware, the job of a processor.
5. FEATURES OF PYTHON
INTERPRETER
INTERACTIVE EDITING
USE OF VARIABLES INITIALIZED IN THE PREVIOUS PROMPTS
WRITING THE COMPLETE CODE IN IT WITH A READLINE FACILITY.
TO GET COMMAND-LINE EDITING, ONE CAN PRESS CTRL+P,
WHICH GIVES A BEEP INDICATING THE MODE IS ACTIVATED.
THE PYTHON INTERPRETER IS USER FRIENDLY AND ITS FEATURES
INCLUDE:
6. GETTING STARTED WITH THE
PYTHON INTERPRETER
In Windows, it looks like Command Prompt.
And on Mac, it looks like a terminal.
Read the lines of the code
Evaluate and execute the code
Print the output of the code (if any) to the console
Looping to repeat the above process
To open the Python interpreter, installed in the system, search in the Start menu. Then click on Python
3.9 or another, depending on the installed version.
The interpreter environment works using REPL:
The picture below shows the Python interpreter once opened. Small description of the Python version,
storage, etc. Along with this, you can see three arrows (>>>), called prompt.
7. CONCLUSION
pythongeeks.org
HENCE, WE LEARNED THAT PYTHON IS AN INTERPRETER
LANGUAGE AND HOW THE CODE IS EXECUTED
INTERNALLY. WE ALSO GOT OUR HANDS DIRTY WITH
SOME CODING IN AN INTERPRETER AND GOT FAMILIAR
WITH ITS ENVIRONMENT.