Unit-1_PythonIntroduction
Unit-1_PythonIntroduction
What is Python ?
● ABC language.
● Modula-3
Why the Name Python?
There is a fact behind choosing the name Python. Guido van Rossum was reading the script of a
popular BBC comedy series "Monty Python's Flying Circus". It was late on-air 1970s.
Van Rossum wanted to select a name which unique, sort, and little-bit mysterious. So he decided
to select naming Python after the "Monty Python's Flying Circus" for their newly created
programming language.
Features of Python
● Easy to use and Read - Python's syntax is clear and easy to read, making it an ideal
language for both beginners and experienced programmers. This simplicity can lead to
faster development and reduce the chances of errors.
Example: print(“hello”)
● Dynamically Typed - The data types of variables are determined during run-time. We do
not need to specify the data type of a variable during writing codes.
Example : x=10
print(x)
● Compiled and Interpreted - Python code first gets compiled into bytecode, and then
interpreted line by line. When we download the Python in our system form org we
download the default implementation of Python known as CPython. CPython is
considered to be Compiled and Interpreted both.
● Rich Standard Library - Python comes with several standard libraries that provide
ready-to-use modules and functions for various tasks, ranging from web development and
data manipulation to machine learning and networking.
Python directly doesn’t convert its code into machine code, something that hardware can
understand. It converts it into something called bytecode. So within Python, compilation
happens, but it’s just not in a machine language. It is into byte code (.pyc or .pyo) and this byte
code can’t be understood by the CPU. So we need an interpreter called the Python virtual
machine to execute the byte codes.
● Step 1: The Python compiler reads a Python source code or instruction in the code editor.
In this first stage, the execution of the code starts.
● Step 2: After writing Python code it is then saved as a .py file in our system. In this,
there are instructions written by a Python script for the system.
● Step 3: In this the compilation stage comes in which source code is converted into a byte
code. Python compiler also checks the syntax error in this step and generates a . pyc file.
● Step 4: Byte code that is .pyc file is then sent to the Python Virtual Machine(PVM)
which is the Python interpreter. PVM converts the Python byte code into
machine-executable code and in this interpreter reads and executes the given file line by
line. If an error occurs during this interpretation then the conversion is halted with an
error message.
● Step 5: Within the PVM the bytecode is converted into machine code that is the binary
language consisting of 0’s and 1’s. This binary language is only understandable by the
CPU of the system as it is highly optimized for the machine code.
● Step 6: In the last step, the final execution occurs where the CPU executes the machine
code and the final desired output will come as according to your program.