Introduction To Python
Introduction To Python
• Python is a popular programming language, released in 1991 that combine the features
of C and Java.
• Python is a widely used general-purpose, high level programming language.
NB: The high-level language is easy to read, write, and maintain as it is written in English like
words.
• It was created by Guido van Rossum (Dutch Programmer) and further developed by the Python
Software Foundation.
• The logo of python shows 2 intertwined snakes.
Some most popular companies on the internet also used Python programming.
• Reddit
• Google
• Facebook
• Dropbox
• Spotify
• Instagram
• IBM
• Netflix
• It is used for:
o Web development (server-side),
o Software development
o Desktop GUI applications
o Mathematics
o Data Science
o Scientific Computing
o Mobile App development
o Machine Learning
• Its syntax allows programmers to express their concepts in fewer lines of code.
• Python is a programming language that lets you work quickly and integrate systems more efficiently.
• There are two major Python versions: Python 2 and Python 3. Both are quite different.
Why Python?
• Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
• Python has a simple syntax similar to the English language.
• Python has syntax that allows developers to write programs with fewer lines than some other
programming languages.
• Python runs on an interpreter system, meaning that code can be executed as soon as it is written.
• Python can be treated in a procedural way, an object-oriented way or a functional way.
Features in Python
1. Free and Open Source
• Python language is freely available at the official website.
• Since it is open-source, this means that source code is also available to the public. So, you
can download it, use it as well as share it.
2. Easy to code
• Python is a high-level programming language.
• Python is very easy to learn the language as compared to other languages like C, C#,
Javascript, Java, etc.
• It is very easy to code in the Python language and anybody can learn Python basics in a few
hours or days. It is also a developer-friendly language.
3. Easy to Read
• Python’s syntax is really straightforward. The code block is defined by the indentations rather
than by semicolons or brackets.
4. Object-Oriented Language
• One of the key features of Python is Object-Oriented programming.
• Python supports object-oriented language and concepts of classes, object encapsulation, etc.
5. GUI Programming Support
• Graphical User interfaces can be made using a module such as PyQt5, PyQt4, wxPython,
or Tk in python.
• PyQt5 is the most popular option for creating graphical apps with Python.
6. High-Level Language
• Python is a high-level language. When we write programs in Python, we do not need to
remember the system architecture, nor do we need to manage the memory.
7. Extensible feature
• Python is an Extensible language. We can write some Python code into C or C++ language
and also, we can compile that code in C/C++ language.
8. Easy to Debug
• Developers do not need to write int y = 18 if the integer value 15 is set to y. You may just
type y=18.
a = 10
b = 10
print ("Sum ", (a + b))
Output:
Sum 20
Suppose the above python program is saved as first.py. Here first is the name and .py is the
extension. The execution of the Python program involves 2 Steps:
• Compilation
• Interpreter
Compilation
• The program is converted into byte code.
• Byte code is a fixed set of instructions that represent arithmetic, comparison, memory
operations, etc.
• It can run on any operating system and hardware.
• The byte code instructions are created in the .pyc file.
Interpreter
• The next step involves converting the byte code (.pyc file) into machine code.
• This step is necessary as the computer can understand only machine code (binary code).
• Python Virtual Machine (PVM) first understands the operating system and processor in the
computer and then converts it into machine code. Further, these machine code instructions
are executed by processor and the results are displayed.
Python is a high-level language and its syntax is very simple. It does not need any semicolons or braces
and looks like English. Thus, it is beginner-friendly.
2. Dynamic Typing
In Python, there is no need for the declaration of variables. The data type of the variable gets assigned
automatically during runtime, facilitating dynamic coding.
It is free and also has an open-source licence. This means the source code is available to the public for
free and one can do modifications to the original code. This modified code can be distributed with no
restrictions.
This is a very useful feature that helps companies or people to modify according to their needs and use
their version.
4. Portable
Python is also platform-independent. That is, if you write the code on one of the Windows, Mac, or
Linux operating systems, then you can run the same code on the other OS with no need for any changes.
Python comes with a wide range of libraries like NumPy, Pandas, Tkinter, Django, etc.
The python package installer (PIP) helps you install these libraries in your interpreter/ IDLE. These
libraries have different modules/ packages. These modules contain different inbuilt functions and
algorithms. Using these make the coding process easier and makes it look simple.
6. Wide Range of Applications
Python has many applications like web development, making desktop GUIs, app development,
artificial intelligence, data science, etc. It has become a preferred language by the professionals in
many areas like engineering, mathematics and science.
In addition to having libraries like CPython and Jython, it can extend to other languages like C, C++.
This feature helps while building projects.
It can also integrate with C, C++, and Java, helping in cross-platform development and also in using
the strong features of each language. This makes Python a powerful language.
8. Interpreted Language
Python is an interpreted language. The code gets executed line by line till an error is encountered if
any.
If an error occurs at a line, it stops execution and gives that error to the console. This leads to an
easier and step-by-step debugging process.
It is a procedural, functional, and object-oriented language. Procedural means the code gets executed
in the top to bottom fashion.
A functional language works based on functions, rather than just statements. A function is a collection
of codes that takes input and gives output.
It is used for implementation in big projects and software like YouTube, Google, Yahoo. It is also a
preferred language by many companies in various fields like education, medical, research, etc.
Python also excels in managing its memory by using a separate library for this purpose. It uses a private
heap to hold all the objects and data structures. And a built-in memory manager handles this heap. This
property of Python makes it stand out from the other programming languages.
12. Improved Productivity
The fact that the syntax of python is very easy and short, allows more productivity. Developers can
focus more on the algorithm, rather than on coding.
Python has an active and big community that helps in doing continuous additions to it. It also allows
the availability of the information on Python at ease to the developer.
Are you wondering how this feature under advantage also is coming as a disadvantage?
Then the answer is Yes! Its simplicity is making it hard for a programmer to adjust to the syntax of the
other programming languages.
For example, a coder might forget to declare a variable in C falling into an error.
The interpreter in Python executed the code line by line, which increases the overall time. The dynamic
typing feature also decreases the speed. This is because it has to do extra work during runtime. It
requires a large amount of memory too!
Python has many applications on the server-side. But it is hardly seen on the client-side or in mobile
applications. The main reasons for this are:
Python databases are weak compared to other technologies like JDBC (Java DataBase Connectivity)
and ODBC (Open DataBase Connectivity). This limits its use in high enterprises.
5. Runtime Errors due to dynamic typing
Because it’s a dynamically typed language, you do not need to declare any variable and a variable
storing an integer can store a string later. This might happen unnoticeably but leads to runtime errors
while doing operations.
This is a restriction on the design of the Python programming language. Also, all errors show up only
during runtime. So, it is difficult to test.