Background:
I am totally a layman of python. Of course I know it is a programming language and it is popular. There are millions and millions people who can use python in the world but for me. I have to learn it immediately because I have no time to wait and to waste.
Beginning
Today I downloaded the Python_3.8 and installed it. This task is easy.
I followed the instruction from Liaoxuefeng https://www.liaoxuefeng.com/wiki/1016959663602400 and read a python book named Snake Wrangling for Kids. I suppose I am a kid too in this filed.
I guess the 2nd file Python 3.8(64-bit) is the python interpreter. that is where we write the Python code and run it.
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.
Well, my python interpreter is a CPython interpreter.
The following paragraph describes how a Python interpreter works. I can't understand it completely now but one day I will.
What happens when you run a Python Code?
On running a Python code, say a simple program that prints “Hello, World!”, then the following steps happen:
- The program gets converted into an intermediate code, called bytecode. This is also binary but is not understood by the processor.
- 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).
- The compiler converts the source code, the “Hello, World!” program, into the byte code, which is platform-independent and understood by the PVM.
- PVM reads the byte code and executes it on the hardware, the job of a processor.
Interactive mode is a command line shell which gives immediate feedback for each statement, while running previously fed statements in active memory. As new lines are fed into the interpreter, the fed program is evaluated both in part and in whole. Interactive mode is a good way to play around and try variations on syntax.