Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

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.

Why was Python developed?


The reason why Guido Van Rossum embarked on the move to design a new programming language is that he
wanted a language that could offer a simple syntax. This motivation led to the development of a new language
named Python.
But you may be wondering why just the name Python?
No! One of the interests of Rossum was watching comedy. He was a great fan of the comedy series in the late
seventies. As a result, the name of the language was borrowed from the “Monty Python’s Flying Circus.”

Python Applications Examples

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.

What can Python do?

• Python can be used on a server to create web applications.


• Python can be used alongside software to create workflows.
• Python can connect to database systems. It can also read and modify files.
• Python can be used to handle big data and perform complex mathematics.

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

• Learning Python is quite simple.

• 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

• Excellent information for mistake tracing.


• You will be able to quickly identify and correct the majority of your program’s issues once
you understand how to interpret Python’s error traces.
9. Python is a Portable language
• Python language is also a portable language. For example, if we have Python code for
windows and if we want to run this code on other platforms such as Linux, Unix, and Mac
then we do not need to change it, we can run this code on any platform.
10. Python is an integrated language
Python is also an integrated language because we can easily integrate Python with other languages
like C, C++, etc.
11. Interpreted Language
• Python is an Interpreted Language because Python code is executed line by line at a time.
like other languages C, C++, Java, etc. there is no need to compile Python code this makes it
easier to debug our code.
• The source code of Python is converted into an immediate form called bytecode.
12. Large Standard Library
• Python has a large standard library that provides a rich set of modules and functions so you
do not have to write your own code for every single thing.
• There are many libraries present in Python such as regular expressions, unit-testing, web
browsers, etc.
13. Dynamically Typed Language
• Python is a dynamically-typed language. That means the type (for example- int, double, long,
etc.) for a variable is decided at run time not in advance because of this feature we don’t
need to specify the type of variable.

14. Frontend and backend development


• With a new project py script, you can run and write Python codes in HTML with the help of
some simple tags <py-script>, <py-env>, etc. This will help you do frontend development
work in Python like javascript.
• Backend is the strong forte of Python it’s extensively used for this work cause of its
frameworks like Django and Flask.

15. Allocating Memory Dynamically


• In Python, the variable data type does not need to be specified.

• The memory is automatically allocated to a variable at runtime when it is given a value.

• Developers do not need to write int y = 18 if the integer value 15 is set to y. You may just
type y=18.

Understanding the Execution of Python Program


Example:

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.

Fig : Execution of Python Program


However, the interpreter inside the PVM translates the program line by line thereby consuming a lot
of time. To overcome this, a compiler known as Just In Time (JIT) is added to PVM. JIT compiler
improves the execution speed of the Python program. This compiler is not used in all Python
environments like CPython which is standard Python software.

Advantages of Python Programming Language

1. Easy to read, learn and code

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.

Due to its simplicity, its maintenance cost is less.

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.

3. Free, Open Source

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.

This is called Write Once Run Anywhere (WORA).

5. Extensive Third-Party Libraries

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.

7. Extensible and Integrable to Other Programming Languages

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.

9. Functional, Object-Oriented, and Procedural

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.

Information is treated as a real-world object with properties and behaviours in object-orientated


language.

10. Involvement in Large Projects.

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.

11. Memory Management

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.

13. Vast Community

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.

Some other advantages include

▪ Integration to IoT devices like Arduino, Raspberry Pi, etc.


▪ It does not lead errors to a segmentation fault.
▪ It is also very easy for asynchronous coding, like coding blocks including loops.
Disadvantages of Python

1. It’s Simple Nature

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.

2. Slow Speed and Memory Inefficient

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!

3. Weak Mobile Computation

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:

▪ It occupies a lot of memory.


▪ This makes the process slow.
▪ It also does not facilitate security
4. Poor Database Access

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.

There are some other disadvantages like:

▪ It does not allow multithreading. To achieve multithreading in Python, a developer can


extend Python to C extensions, PyPy, JPython, and IronPython.
▪ Besides being a functional programming language, it does not support functional
optimization. In addition, it also falls behind due to a lack of basic features.
Garbage collection
It is the process by which shared computer memory is cleaned which is currently being put to use by
a running program when that program no longer needs that memory. With garbage collection, that
freed memory can be used by another program

You might also like