/    Sign up×
Articles /Pin to ProfileBookmark

What is Python: How the Compiler (Interpreter) Works?

In this article, you will learn more details about what Python is and how the Python compiler (interpreter) works, Also you will learn how to write a Python program on your local machine.

Let’s get started.

What is Python

Python is a high level interpreted language which can do many applications in many platforms such as desktop, mobile, machine learning and so many else.

Python is fully depending on many interpreters; So, I am going to explain how the default Python interpreter works.

Before getting started, you have to know why did they design it ?

Python was come instead of the ABC programming language, which was working on the Amoeba operating system.

The first version of python was released in 1994 developed by Guido van Rossum Dutch programmer which called “benevolent dictator for life” in python community

The second version was released in 2000, and it called Python 2.0, This is contained some new features such as comprehensions, translate a small texts, and collecting system.

Anyway, python 3 was released in 2008 and called with “Py3K”.

In the next section, I will move to how the python interpreter works behind the scene.

How Does Python Interpreter Work?

The default python interpreter name is “CPython” which already written in the C programming language.

Anyway, in the python interpreter, the first process is starting with the tokenization which is analyzing the python code and doing some tasks such as: deleting comments, ensuring from the python indentation and the code syntax is written correctly.

If the python interpreter found an error, it will stop the process immediately and expose the error message for the developer.

The following phase is the AST which called Abstract syntax tree; it is a big structure that generated to represent the Python code in a tree that already created from tokenization.

Once the interpreter finished the AST, it will send it to the parser to generate the byte code which is the machine language.

Here Python is initializing the Python Virtual Machine. This phase is responsible for some instructions to execute the byte code and rendering the results back.

In the next section, I will explain how to install Python on your operating system. But if you don’t need to install Python you can use any Online Python Compiler using your browser to write and run the following Python example.

Installing Python On Ubuntu and Windows Operating System

To install python on Ubuntu operating system, you have to run the following commands using your terminal.

Firstly, update the repository using the below command.

Sudo apt update

Then install python 3.

Sudo apt install python3

Anyway, to install the python software on your Windows you have to download the Python installer from the official page.

Let’s write your first program with Python.

Write Your First Program with Python

It is so easy to write “Hello World” Program with python.

Firstly, you have to create a page ended with py extension you can rename as you like. I will choose “index.py”. Then copy and paste the following python code.

print("Hello World")

Then save it and open your terminal or the CMD and run the following command to execute the python code.

python index.py

You will see the output in your CMD or terminal

Thank you for reading, you can see more of my articles on CodedTag





Help @mich spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ

legal: ({
terms: of use,
privacy: policy
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,