Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Unit-1_PythonIntroduction

Python is a high-level, dynamically typed programming language that supports multiple programming paradigms and was created by Guido Van Rossum in the late 1980s. It features a simple syntax, automatic memory management, and cross-platform compatibility, making it suitable for various applications. The language's source code is converted into bytecode and executed by the Python Virtual Machine, distinguishing it from traditional compiled languages.

Uploaded by

shantanu270805
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Unit-1_PythonIntroduction

Python is a high-level, dynamically typed programming language that supports multiple programming paradigms and was created by Guido Van Rossum in the late 1980s. It features a simple syntax, automatic memory management, and cross-platform compatibility, making it suitable for various applications. The language's source code is converted into bytecode and executed by the Python Virtual Machine, distinguishing it from traditional compiled languages.

Uploaded by

shantanu270805
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Python Programming

What is Python ?

Python is a general-purpose, dynamically typed, high-level, compiled and interpreted,


garbage-collected, and purely object-oriented programming language that supports procedural,
object-oriented, and functional programming.

Python History and Versions

● Python laid its foundation in the late 1980s.


● The implementation of Python was started in December 1989 by Guido Van Rossum at
CWI in Netherland.
● In February 1991, Guido Van Rossum published the code (labeled version 0.9.0) to
alt.sources.
● In 1994, Python 1.0 was released with new features like lambda, map, filter, and reduce.
● Python 2.0 added new features such as list comprehensions, garbage collection systems.
● On December 3, 2008, Python 3.0 (also called "Py3K") was released. It was designed to
rectify the fundamental flaw of the language.
● ABC programming language is said to be the predecessor of Python language, which was
capable of Exception Handling and interfacing with the Amoeba Operating System.

● The following programming languages influence 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)

● High-level - High-level language means human readable code.

● 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.

● Garbage Collected - Memory allocation and deallocation are automatically managed.


Programmers do not specifically need to manage the memory.

● Purely Object-Oriented - It refers to everything as an object, including numbers and


strings.
● Cross-platform Compatibility - Python can be easily installed on Windows, macOS,
and various Linux distributions, allowing developers to create software that runs across
different operating systems.

● 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.

● Open Source - Python is an open-source, cost-free programming language. It is utilized


in several sectors and disciplines as a result

Internal working of Python

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.

How is Python Source Code Converted into Executable Code


The Python source code goes through the following to generate an executable code

● 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.

Difference between Compiler and Interpreter:

You might also like