What is Python? Write your First Python Program

In this tutorial, you will understand what python is, and how the online python compiler works, also you will understand how the CPython interpreter works.

Firstly, Python is a scripting language written in C programming language, which can work for web applications, desktop, machine learning, and so many else.

Anyway, Python is a high-level programming language based on the CPython interpreter to translate the written source code.

The CPython interpreter the following steps to send us the final output.

  1. Lexical analysis to check the source code and generating the byte code.
  2. Python virtual machine to send the output.

Anyway, in the next paragraphs I am going to discuss more details about the CPython interpreter. Let's get started.

1- Analyzing the Source Code

Once the source code is received by the interpreter. it starts the analysis to check if this source code has errors in syntax or not and also removes all white spaces then evaluates the response time before sending it to the virtual machine.

Once it finished, the compiler generates the byte code and send it to the virtual machine.

2- Python Virtual Machine

This is called PVM, which is a program can provide an environment to convert the byte code into binary bits (the machine language).

This machine code produces the final output of the source code, and that can be done through the python module libraries.

Write a Python Program

In this section, you will learn how to write your first program with python, the scripting language.

But before you do that, you have to make sure that you already installed the python software on your operating system.

If you don't have python software on your operating system, you can use the free online python compiler to check your code result.

And to see the python version, you have to copy and paste the following code into our online python compiler. Then click on the “run” button to see the result.

  import sys
  print( sys.version )

The output of the online python compiler would be like the following image.

python-online-compiler.jpg

On the other hand, if you like to see the current installed version on your operating system, you have to use the following command using the terminal or command prompt.

  python

The following image shows you the result on the command line interface.

python-verion.jpg This article is published by the CodedTag team. Stay tuned for our next articles.

Thank you for reading.