Introduction To Python

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 58

INTRODUCTION

OF Python
What is Python and Histroy of Python:
Python is a general-purpose, dynamic, high-level, and interpreted programming language. It supports
Object Oriented programming approach to develop applications. It is simple and easy to learn and
provides lots of high-level data structures. Python is an easy-to-learn yet powerful and versatile scripting
language, which makes it attractive for Application Development. With its interpreted nature, Python's
syntax and dynamic typing make it an ideal language for scripting and rapid application development.
Python supports multiple programming patterns, including object-oriented, imperative, and functional or
procedural programming styles. Python is not intended to work in a particular area, such as web
programming. It is a multipurpose programming language because it can be used with web, enterprise,
3D CAD, etc. We don't need to use data types to declare variable because it is dynamically typed, so we
can write a=10 to assign an integer value in an integer variable.
Python makes development and debugging fast because no compilation step is included in Python
development, and the edit-test-debug cycle is very fast. Python has many web-based assets, open-
source projects, and a vibrant community. Learning the language, working together on projects,
and contributing to the Python ecosystem are all made very easy for developers. Because of its
straightforward language framework, Python is easier to understand and write code in. This makes
it a fantastic programming language for novices. Additionally, it assists seasoned programmers in
writing clearer, error-free code. Python is an open-source, cost-free programming language. It is
utilized in several sectors and disciplines as a result. In Python, code readability and
maintainability are important. As a result, even if the code was developed by someone else, it is
easy to understand and adapt by some other developer. Python has many third-party libraries that
can be used to make its functionality easier. These libraries cover many domains, for example, web
development, scientific computing, data analysis, and more.
Python is an object-oriented, high-level programming language. Object-oriented means this lang
uage is based around objects (such as data) rather than functions, and high-level means it's easy f
or humans to understand.
You can find examples of Python at work in many of the technologies we use on a daily basis, ta
ke YouTube as one example and the processes behind search engines as another.
Python is used to create web and mobile software, in artificial intelligence (AI) and machine lear
ning (ML), to perform data manipulation and analysis, and much
much more.
Python is aopen-source, Python is free for anyone to use. The added benefit of this is that anyone
can create additional tools, libraries, and frameworks for Python that other users can take
advantage of. For example, there are premade Python libraries for everything from chatbots to
cryptography.
The thriving community of Python users helps further this language's functionalities and
applications.
Python is a High-Level Language , High level language is a noun. A computer programming language that
resembles natural language or mathematical notation and is designed to reflect the requirements of a problem;
examples include Ada, BASIC, C, COBOL, FORTRAN, Pascal: See also machine code.
Python is a powerful yet easy-to-use programming language developed by Guido van Rossum, first released in
1991. With Python, you can quickly write a small project. But Python also scales up nicely and can be used for
mission-critical, commercial applications. If you check out any Python documentation, you may notice an
Times New Roman
alarming number of references to spam, eggs, and the number 42. These references all pay homage to Monty
Python, the English comedy troupe that inspired Python’s name. Even though Guido van Rossum named
Python after the group, the official mascot of the language has become the python snake. (Which is really for
the best, since it would be pretty hard to fit six British comedians’ faces on a program icon anyway.)
Python is a widely-used general-purpose, high-level programming language. It was initially
designed by Guido van Rossum in 1991 and developed by Python Software Foundation. It
was mainly developed for emphasis on code readability, and its syntax allows programmers
to express concepts in fewer lines of code.
In the late 1980s, history was about to be written. It was that time when working on Python
started. Soon after that, Guido Van Rossum began doing its application-based work in
December of 1989 at Centrum Wiskunde & Informatica (CWI) which is situated in the
Netherlands. It was started firstly as a hobby project because he was looking for an
interesting project to keep him occupied during Christmas. The programming language in
which Python is said to have succeeded is ABC Programming Language, which had
interfacing with the Amoeba Operating System and had the feature of exception handling.
He had already helped to create ABC earlier in his career and he had seen some issues
with ABC but liked most of the features. After that what he did was really very clever.
He had taken the syntax of ABC, and some of its good features. It came with a lot of
complaints too, so he fixed those issues completely and had created a good scripting
language that had removed all the flaws. The inspiration for the name came from BBC’s
TV Show – ‘Monty Python’s Flying Circus’, as he was a big fan of the TV show and
also he wanted a short, unique and slightly mysterious name for his invention and hence
he named it Python! He was the “Benevolent dictator for life” (BDFL) until he stepped
down from the position as the leader on 12th July 2018. For quite some time he used to
work for Google, but currently, he is working at Dropbox.
The language was finally released in 1991. When it was released, it used a lot fewer
codes to express the concepts, when we compare it with Java, C++ & C. Its design
philosophy was quite good too. Its main objective is to provide code readability and
advanced developer productivity. When it was released it had more than enough
capability to provide classes with inheritance, several core data types exception handling
and functions.
Following are the illustrations of different versions of Python along with the timeline.
Python 3.10.4 is the latest stable version.
The two of the most used versions has to Python 2.x & 3.x. There is a lot of competition
between the two and both of them seem to have quite a number of different fanbases.
For various purposes such as developing, scripting, generation, and software testing, this
language is utilized. Due to its elegance and simplicity, top technology organizations like
Dropbox, Google, Quora, Mozilla, Hewlett-Packard, Qualcomm, IBM, and Cisco have
implemented Python.
Python has come a long way to become the most popular coding language in the world.
Python has just turned 30 and just recently at pycon22(python conference) a new feature
was released by Anaconda foundation it’s known as pyscript with this now python can be
written and run in the browser like javascript which was previously not possible, but it still
has that unknown charm & X factor which can be clearly seen from the fact that Google
users have consistently searched for Python much more than they have searched for Kim
Kardashian, Donald Trump, Tom Cruise, etc.
Python Is Object-Oriented :

Object-oriented programming (OOP) is a modern approach to solving problems with computers.


It embodies an intuitive method of representing information and actions in a program. It’s
certainly not the only way to write programs, but, for large projects, it’s often the best way
to go.
Languages like C#, Java, and Python are all object-oriented. But Python does them one better.
In C# and Java, OOP is not optional. This makes short programs unnecessarily complex, and
it requires a bunch of explanation before a new programmer can do anything significant.
Python takes a different approach. In Python, using OOP techniques is optional. You have all of
OOP’s power at your disposal, but you can use it when you need it. Got a short program
that doesn’t really require OOP? No problem. Got a large project with a team of programmers.
Python Is a “Glue” Language :
Python can be integrated with other languages such as C, C++, and Java. This means that a
programmer can take advantage of work already done in another language while using Python.
It also means that he or she can leverage the strengths of other languages, such as the extra
speed that C or C++ might offer, while still enjoying the ease of development that’s a hallmark
of Python programming.
Python programs are platform independent, which means that regardless of the operating
system you use to create your program, it’ll run on any other computer with Python. So if you
write a program on your PC, you can e-mail a copy to your friend who runs Linux or to your
aunt who has a Mac, and the program will work.
Why Learn python
Python is Beginner Friendly:For starters, the language is an excellent place to begin if
you’re new to coding. One of the biggest hurdles for aspiring coders is the daunting task
of learning a new language that looks nothing like what they’re used to reading and
writing. However, Python features English syntax and was designed to be
concise and easy to read all of which makes it more accessible to first-time coders than
many other languages.
Python is also easy to learn because it is an interpreted programming language. This
means that you can run each line of code once you have finished writing it, allowing you
to immediately check it and make adjustments if needed a big help to those who are still
learning and a time-saver for coders everywhere.
Python is Versatile:Python is highly versatile. You can use it for both small and complex tasks,
and it is used across many different industries — from its more common applications in data
science and software engineering to environments like mobile app development, artificial
intelligence, and machine learning.. This multifaceted use is due to the wide array of Python
libraries available (over 125,000, to be specific). Libraries are collections of pre-written code in
a particular language that anyone can access, meaning that once you’ve learned the basics of
Python, you’ll likely be able to understand and use a huge amount of code developed by other
programmers.Another important aspect of Python’s versatility is its ability to run with other
programming languages. A few common examples of Python implementation with other
languages are Jython (Python integrated with Java) and CPython (Python integrated with C).
Lastly, Python offers cross-platform functionality, meaning that it will function properly
whether you’re working with Windows, Linux, or macOS.
Python Developer Roles Are in High Demand: Python developer roles are in high demand, as
many major companies — including DropBox, Netflix, and Facebook — use it. Google has even
made its own Python style guide. Python developer jobs are also comparatively lucrative.
According to Indeed, Python developers earn an average salary of $108,391, which makes it the
fourth-most lucrative programming language behind Ruby ($120,174), C++ ($114,000), and
JavaScript ($111,623). Python developers also have the opportunity to earn a high salary with less
experience, according to StackOverflow
Python Boasts a Supportive Community:When you’re learning a new programming language
particularly after you’ve completed your bootcamp course or degree you’ll want to feel confident
that you have a community of programmers you can turn to with questions when an issue comes
up. One major benefit of Python is its robust and supportive online community, as evidenced by the
1.5 million gitub repositories that make Python the platform’s second-largest community. Python
also has its own network of robust community forums, where users can discuss everything from
workflow to software development, and Python users often organize meetups around the world to
build community and knowledge bases.
Python Is the Fastest-Growing Programming Language:When it comes to Python’s popularity and
growth rate, the numbers don’t lie. According to the PYPL PopularitY of Programming Language
Index, Python is the most-searched programming language on the internet and that doesn’t look
like it will be changing any time soon. According to Stack Overflow Python is also the fastest-
growing programming language, and TIOBE gave it the 2020 Programming Language of the Year
award as it gained popularity faster than any other language. Part of this acclaim is due to
Python’s usefulness in the world of data science; as fields like machine learning, data modeling,
and AI grow, so too does the demand for Python-related skills. All of this means that, if you’re
looking for a new programming language to learn or looking to transition into the field of
programming Python is a wise choice.
Now the question arise what you can do with python , Let's see :
1. Data Science :
According to a survey from Kaggle an online community for data scientists, Python is the
field’s most-used programming language. In addition to Python’s time-saving libraries, the
language’s ability to analyze large data sets very quickly and carry out repetitive tasks make its
popularity more than warranted.

2. Web Development:
Since Python is such a flexible programming language, it can make it easier to build complex
web utilities. Python’s various web frameworks are especially usefullike the popular Django,
which can make building both back end and client-side functionality easier and faster. Even
large companies use Python for web development; both Google and YouTube have used it
extensively for many of their digital infrastructures.
3. App Development:
Python is an excellent choice for anyone looking to get into app development. It’s an ideal
language for prototyping because of its lower development time and effort. As with web
development, app development is made easy by Python’s cross-platform abilities.
Specifically, Python has recently become popular in the fast-growing sectors of blockchain
app development and gaming app development thanks to its robust frameworks and real-time
testing.
Where is Python Used
Python is often used as a support language for software developers, for build control and
management, testing, and in many other ways. SCons for build control. Buildbot and Apache
Gump for automated continuous compilation and testing. Roundup or Trac for bug tracking
and project management.Let us take a look at some of the real-world uses of Python:
1. Web Development :
Famously known as the go-to programming language for web development, Python has an
important role to play in it. Python comes with multiple web development frameworks like
Pyramid, Django, and Flask. These frameworks are packed with standard libraries that allow
easy protocol integration and lead to a reduction in development time.
2. Artificial Intelligence and Machine Learning:
One of the most important uses of Python is in AI. The reason for it is that Python is a
stable language that has the capacity to handle the computations required to build machine
learning models. Its libraries like Keras, Pandas, NumPy and others are suitable for
machine learning applications. Furthermore, it is used in multiple AI solutions like
advanced computing, image recognition, data processing, and more.
3. Enterprise Applications:
Enterprise applications are used to serve the needs of an organization rather than
individual users. The use of Python in building enterprise applications is done as it is a
robust language that can handle multiple requests of databases at once. Even though the
use of Python varies from one enterprise to another, its core functionalities like its
readability, functionality, and scalability remain the same. Enterprise applications are one
of the most notable uses of Python. Tryton and Odoo are platforms that help in developing
such enterprise applications.
4. Education Sector:
One of the other important uses of Python is seen in developing online courses and education
programs. It is an easy to learn programming language for beginners since its syntax matches
that of English. It offers a novice, a standard library, and a variety of resources to understand
the language, thus making the learning curve easier. This is one of the many reasons why
Python is the preferred programming language for beginners for the education program’s
development at both basic and advanced levels.
5. Web Scraping Applications:
It refers to the scraping of huge quantities of data by companies for extracting customer
information to make profitable decisions. Tools like PythonRequest, Selenium,
MechanicalSoup are used in Python programming for building web scraping applications.
Thanks to Python’s ability to build software that can process large amounts of data, this
language is a clear winner in making web scraping applications.
4. Education Sector:
One of the other important uses of Python is seen in developing online courses and education
programs. It is an easy to learn programming language for beginners since its syntax matches
that of English. It offers a novice, a standard library, and a variety of resources to understand
the language, thus making the learning curve easier. This is one of the many reasons why
Python is the preferred programming language for beginners for the education program’s
development at both basic and advanced levels.
5. Web Scraping Applications:
It refers to the scraping of huge quantities of data by companies for extracting customer
information to make profitable decisions. Tools like PythonRequest, Selenium,
MechanicalSoup are used in Python programming for building web scraping applications.
Thanks to Python’s ability to build software that can process large amounts of data, this
language is a clear winner in making web scraping applications.
6. Game Development:
This one had to be featured in the top 10 uses of Python. And why not? Python has time and
again displayed its capacity of contributing to the gaming industry in a massive way.
Remember Battlefield 2; one of the most popular games in the early 2000s? It was developed
using the Python programming language. Some of the top Python frameworks that are used in
game development include Pygame, PyKyra, Pyglet, PyOpenGL, Kivy, Panda3D, Cocos2D,
and more!

7. Software Development:
One of the prime uses of Python is that it is used by software developers. Python simplifies
the software development process for complex apps. It is used for project management, as a
support programming language, to build control, and testing.
8. Desktop GUI:
One of the top uses of Python is developing a desktop GUI. We know that Python is a
simple, stable, easy to learn, open-source, and platform-independent programming
language. These factors work in their favour of being used for developing desktop GUI.
Toolkits like PyQt, PyGUI, and WxPython are widely used for building high-quality GUIs
efficiently.

9. Operating Systems:
Python is a powerful programming language and so is C. When these two are combined
together, many operating systems are developed. The use of Python in creating operating
systems came to life with Ubuntu’s Ubiquity, and Red Hat’s Anaconda and Fedora. OS
made with Python are running billions of computers today.
10. Data Science:
We all know that data science is one of the most in-demand skills in the market. Knowledge
of data science is a sought-after skill in IT, manufacturing, or eCommerce. This is where
Python steps in. Its multiple libraries, such as Pandas, TensorFlow, NumPy, etc help in
extracting valuable information from the data. Libraries like Matplotib and Seaborn further
allow a data science professional to focus on data visualization through graphs and charts. It
won’t be an exaggeration to say that Python is the first thing that any data science
professional needs to know.
Python Popular Frameworks and Libraries
Python is one of the most popular and effective programming languages that contain vast
libraries and frameworks for almost every technical domain. Python frameworks automate
the implementation of several tasks and give developers a structure for application
development. Each framework comes with its own collection of modules or packages that
significantly reduce development time. A Python framework can either be full-stack,
micro, or asynchronous. Before going into the popular Python frameworks in detail, let's
briefly introduce the various types of frameworks.

1.Full-stack Framework:
A full-stack framework contains all the web development requirements. These include
form generators, template layouts, form validation, and lots more.
2.Micro Framework:
Micro frameworks require a bit of manual work from developers. It is used for minimalistic
web application development since it lacks most of the functionality that comes along with
full-stack frameworks.

3.Asynchronous Framework:
Asynchronous frameworks use the asyncio library to run a number of processes concurrently.
They can handle a large number of concurrent connections.
Top 5 Frameworks In Python:
There are a number of Python frameworks available in the market for web development.
Depending on the functionality and key features they provide to the user, here are the top 5
frameworks available in Python:

1.Django:
Django is a popular open-source full-stack Python framework that includes all the necessary
Python features by default. It follows the DRY principle - Don’t Repeat Yourself. Django
uses an ORM or object-relational mapper to map objects to database tables. This helps you
use the object-oriented paradigm to manipulate data from a database. The main databases that
Django works on are Oracle, MySQL, PostgreSQL, and SQLite. It can also work on other
databases using third-party drivers. Here are some more exemplary features of the Django
web framework:
• URL routing
• Authentication
• Template engine
• Database schema migrations
• A plethora of ready-to-use libraries
• More secure as compared to other frameworks

2.Web2Py:
Web2Py is another popular open-source and full-stack Python framework. It is platform-
independent, which means that it can run on all the popular operating systems. Furthermore, it
simplifies the web application development process through its own web-based IDE that includes
a code editor, a debugger, and one-click deployment. Here are some more features of the Web2Py
framework:
• No prerequisites for installation and configuration
• Can read multiple protocols
• Support different platforms
• Data security
• Error tracking mechanism
• Role-based access control
• Backward compatibility

3.Flask:
Flask is a micro-framework for Python. It is lightweight and easily adaptable to suit a developer’s
needs. The Flask framework comes under the BSD license and requires the Werzeug WSGI
toolkit and Jinja2 templates. Here are some of the main features of the Flask framework:
• Fast debugger
• Jinja2 templating
• Unicode-based
• Built-in development server
• HTTP request handling
• WSGI compliance
• Integrated support for unit testing
• RESTful request dispatching
• Secure cookies support
• Ability to plug any ORM
4.Bottle:
Bottle is a micro-framework for prototyping and building simple personal applications.
It was originally meant for building APIs and is considered by developers as one of the
finest Python web frameworks. It also allows developers to work closely with the
hardware to build small and simplistic personal use apps. Here are some of the main
features of the Bottle framework:
• A built-in development server
• Access to form data, cookies, headers, file uploads, cookies, headers, etc.
• Includes plugin support for different databases.
• Routing
• Templating
• Abstraction layer over the WSGI standard
5.CherryPy:
CherryPy is an open-source Python framework that follows a minimalist approach for
building web applications. Released in 2002, it is one of the oldest Python frameworks still
popular today. Unlike other frameworks, you don't need to install the apache server to run
CherryPy. With CherryPy, you can build web applications the same way you would an object-
oriented program. The best thing about this framework is that it allows you to use any type of
technology for creating templates and data access. Here are some more features of using the
CherryPy framework:
• A flexible plugin system
• Built-in support for profiling, coverage, and testing
• Can run on different platforms
• Simplifies running multiple HTTP servers at once
• Encoding
• Authentication
Libraries in Python:Normally, a library is a collection of books or is a room or place where
many books are stored to be used later. Similarly, in the programming world, a library is a
collection of precompiled codes that can be used later on in a program for some specific
well-defined operations. Other than pre-compiled codes, a library may contain
documentation, configuration data, message templates, classes, and values, etc.
A Python library is a collection of related modules. It contains bundles of code that can be
used repeatedly in different programs. It makes Python Programming simpler and convenient
for the programmer. As we don’t need to write the same code again and again for different
programs. Python libraries play a very vital role in fields of Machine Learning, Data Science,
Data Visualization, etc.
Working of Python Library: As is stated above, a Python library is simply a collection of
codes or modules of codes that we can use in a program for specific operations. We use
libraries so that we don’t need to write the code again in our program that is already
available. But how it works. Actually, in the MS Windows environment, the library files
have a DLL extension (Dynamic Load Libraries). When we link a library with our program
and run that program, the linker automatically searches for that library. It extracts the
functionalities of that library and interprets the program accordingly. That’s how we use the
methods of a library in our program. We will see further, how we bring in the libraries in
our Python programs.
Python standard library:
The Python Standard Library contains the exact syntax, semantics, and tokens of Python. It
contains built-in modules that provide access to basic system functionality like I/O and
some other core modules. Most of the Python Libraries are written in the C programming
language. The Python standard library consists of more than 200 core modules. All these
work together to make Python a high-level programming language. Python Standard
Library plays a very important role. Without it, the programmers can’t have access to the
functionalities of Python. But other than this, there are several other libraries in Python that
make a programmer’s life easier. Let’s have a look at some of the commonly used libraries:
• TensorFlow: This library was developed by Google in collaboration with the Brain Team.
It is an open-source library used for high-level computations. It is also used in machine
learning and deep learning algorithms. It contains a large number of tensor operations.
Researchers also use this Python library to solve complex computations in Mathematics
and Physics.
• Matplotlib: This library is responsible for plotting numerical data. And that’s why it is
used in data analysis. It is also an open-source library and plots high-defined figures like
pie charts, histograms, scatterplots, graphs, etc.
• Pandas: Pandas are an important library for data scientists. It is an open-source machine
learning library that provides flexible high-level data structures and a variety of analysis
tools. It eases data analysis, data manipulation, and cleaning of data. Pandas support
operations like Sorting, Re-indexing, Iteration, Concatenation, Conversion of data,
Visualizations, Aggregations, etc.
4. Numpy: The name “Numpy” stands for “Numerical Python”. It is the commonly used
library. It is a popular machine learning library that supports large matrices and multi-
dimensional data. It consists of in-built mathematical functions for easy computations.
Even libraries like TensorFlow use Numpy internally to perform several operations on
tensors. Array Interface is one of the key features of this library.
5. SciPy: The name “SciPy” stands for “Scientific Python”. It is an open-source library
used for high-level scientific computations. This library is built over an extension of
Numpy. It works with Numpy to handle complex computations. While Numpy allows
sorting and indexing of array data, the numerical data code is stored in SciPy. It is also
widely used by application developers and engineers.
6. Scrapy: It is an open-source library that is used for extracting data from websites. It
provides very fast web crawling and high-level screen scraping. It can also be used for
data mining and automated testing of data.
7.Scikit-learn: It is a famous Python library to work with complex data. Scikit-learn is an
open-source library that supports machine learning. It supports variously supervised and
unsupervised algorithms like linear regression, classification, clustering, etc. This library
works in association with Numpy and SciPy.
8.PyGame: This library provides an easy interface to the Standard Directmedia Library (SDL)
platform-independent graphics, audio, and input libraries. It is used for developing video
games using computer graphics and audio libraries along with Python programming language.
9.PyTorch: PyTorch is the largest machine learning library that optimizes tensor
computations. It has rich APIs to perform tensor computations with strong GPU acceleration.
It also helps to solve application issues related to neural networks.
10.PyBrain: The name “PyBrain” stands for Python Based Reinforcement Learning,
Artificial Intelligence, and Neural Networks library. It is an open-source library built for
beginners in the field of Machine Learning. It provides fast and easy-to-use algorithms for
machine learning tasks. It is so flexible and easily understandable and that’s why is really
helpful for developers that are new in research fields.
Use of Libraries in Python Program:
As we write large-size programs in Python, we want to maintain the code’s modularity. For
the easy maintenance of the code, we split the code into different parts and we can use that
code later ever we need it. In Python, modules play that part. Instead of using the same code
in different programs and making the code complex, we define mostly used functions in
modules and we can just simply import them in a program wherever there is a requirement.
We don’t need to write that code but still, we can use its functionality by importing its
module. Multiple interrelated modules are stored in a library. And whenever we need to use
a module, we import it from its library. In Python, it’s a very simple job to do due to its easy
syntax. We just need to use import.
Let’s have a look at exemplar code:
# Importing math library
import math
A = 16
print(math.sqrt(A))
Output:
4.0
Here in the above code, we imported the math library and used one of its methods i.e.
sqrt (square root) without writing the actual code to calculate the square root of a
number. That’s how a library makes the programmers’ job easier. But here we needed
only the sqrt method of math library, but we imported the whole library. Instead of this,
we can also import specific items from a library module.
Importing specific items from a library module
As in the above code, we imported a complete library to use one of its methods. But we could have
just imported “sqrt” from the math library. Python allows us to import specific items from a library.
Let’s look at an exemplar code :
# Importing specific items
from math import sqrt, sin
A = 16
B = 3.14
print(sqrt(A))
print(sin(B))
Output:
4.0
0.0015926529164868282
In the above code, we can see that we imported only “sqrt” and “sin” methods from the math library.
Feautres of python
1. Easy To Learn and Readable Language
Python is extremely easy to learn. Its syntax is super simple and the learning curve of Python is
very smooth. It is extremely easy to learn and code in Python and the indentation used instead
of curly braces in Python makes it very easy to read Python code. Perhaps, because of this, a lot
of schools and universities, and colleges are teaching Python to their students who are beginning
their journey with coding.
2. Interpreted Language
Python is an interpreted language (an interpreted language is a programming language that is
generally interpreted, without compiling a program into machine instructions. It is one where
the instructions are not directly executed by the target machine, but instead, read and executed
by some other program known as the interpreter) and an IDLE (Interactive Development
Environment) is packaged along with Python.
It is nothing but an interpreter which follows the REPL (Read Evaluate Print Loop)
structure just like in Node.js. IDLE executes and displays the output of one line of Python
code at a time. Hence, it displays errors when we are running a line of Python code and
displays the entire stack trace for the error.
3. Dynamically Typed Language
Python is a dynamically typed language. In other words, in Python, we do not need to
declare the data types of the variables which we define. It is the job of the Python
interpreter to determine the data types of the variables at runtime based on the types of the
parts of the expression. Though it makes coding easier for programmers, this property
might create runtime errors. To be specific, Python follows duck typing. It means that “If it
looks like a duck, swims like a duck and quacks like a duck, it must be a duck.”
4. Open Source And Free
Python is an open-source programming language and one can download it for free from Python’s
official website. The community of Python users is constantly contributing to the code of Python
in order to improve it.
5. Large Standard Library
One of the very important features because of which Python is so famous in today’s times is the
huge standard library it offers to its users. The standard library of Python is extremely large with
a diverse set of packages and modules like itertools, functools, operator, and many more with
common and important functionalities in them. If the code of some functionality is already
present in these modules and packages, the developers do not need to rewrite them from scratch,
saving both time and effort on the developer’s end. Moreover, the developers can now focus on
more important things concerning their projects. Also, Python provides the PyPI (Python Package
Index) which contains more packages that we can install and use if we want even more
functionality.
6. High-Level Language
A high-level language (HLL) is a programming language that enables a programmer to write
programs that are more or less independent of a particular type of computer. These languages are said
to be high-level since they are very close to human languages and far away from machine languages.
Unlike C, Python is a high-level language. We can easily understand Python and it is closer to the
user than middle-level languages like C. In Python, we do not need to remember system architecture
or manage the memory.
7. Object Oriented Programming Language
Python supports various programming paradigms like structured programming, functional
programming, and object-oriented programming. However, the most important fact is that the
Object-Oriented approach of Python allows its users to implement the concepts of Encapsulation,
Inheritance, Polymorphism, etc. which is extremely important for the coding done in most Software
Industries as objects map to entities in real-world and lot of real-world problems can be solved using
the Object-Oriented Approach.
8. Large Community Support
With one of the biggest communities on StackOverflow and Meetup, Python has gained
popularity over the years. If we need any kind of help related to Python, the huge community
is always there to answer our queries. A lot of questions about Python have already been
answered on these sites and Python users can reference them as per requirement.
9. Platform Independent
Platform independence is yet another amazing feature of Python. In other words, it means
that if we write a program in Python, it can run on a variety of platforms, for instance,
Windows, Mac, Linux, etc. We do not have to write separate Python code for different
platforms.
10. Extensible and Embeddable
Python is an Embeddable language. We can write some Python code into C or C++ language
and also we can compile that code in C/C++ language. Python is also extensible. It means that
we can extend our Python code in various other languages like C++, etc. too.
11. Graphical User Interface (GUI) Support
Yet another interesting feature of Python is the fact that we can use it to create GUI (Graphical
User Interfaces). We can use Tkinter, PyQt, wxPython, or Pyside for doing the same. Python
also features a large number of GUI frameworks available for it and various other cross-
platform solutions. Python binds to platform-specific technologies.
Install python and environment setup
Python is available on a wide variety of platforms including Linux and Mac OS X. Let's
understand how to set up our Python environment.
• Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX, etc.)
• Win 9x/NT/2000
• Macintosh (Intel, PPC, 68K)
• OS/2
• DOS (multiple versions)
• PalmOS
• Nokia mobile phones
• Windows CE
• Acorn/RISC OS
• BeOS
• Amiga
• VMS/OpenVMS
• QNX
• VxWorks
• Psion
Python has also been ported to the Java and .NET virtual machines

Local Environment Setup:


Open a terminal window and type "python" to find out if it is already installed and which
version is installed. If Python is already installed then you will get a message something
like as follows:
$ python
Python 3.6.8 (default, Sep 10 2021, 09:13:53)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Getting Python
The most up-to-date and current source code, binaries, documentation, news, etc., is
available on the official website of Python https://www.python.org/

You can download Python documentation from https://www.python.org/doc/. The


documentation is available in HTML, PDF, and PostScript formats.
Installing Python
Python distribution is available for a wide variety of platforms. You need to download
only the binary code applicable for your platform and install Python.
If the binary code for your platform is not available, you need a C compiler to compile the
source code manually. Compiling the source code offers more flexibility in terms of
choice of features that you require in your installation.
Here is a quick overview of installing Python on various platforms .
Unix and Linux Installation
Here are the simple steps to install Python on Unix/Linux machine.
• Open a Web browser and go to https://www.python.org/downloads/.
• Follow the link to download zipped source code available for Unix/Linux.
• Download and extract files.
• Editing the Modules/Setup file if you want to customize some options.
Now issue the following commands:
$ run ./configure script
$ make
$ make install
This installs Python at standard location /usr/local/bin and its libraries at
/usr/local/lib/pythonXX where XX is the version of Python.

Using Yum Command


Red Hat Enterprise Linux (RHEL 8) does not install Python 3 by default. We usually use
yum command on CentOS and other related variants. The procedure for installing
Python-3 on RHEL 8 is as follows:
$ sudo yum install python3
Windows Installation
Here are the steps to install Python on Windows machine.
• Open a Web browser and go to https://www.python.org/downloads/.
• Follow the link for the Windows installer python-XYZ.msi file where XYZ is the
version you need to install.
• To use this installer python-XYZ.msi, the Windows system must support Microsoft
Installer 2.0. Save the installer file to your local machine and then run it to find out if
your machine supports MSI.
• Run the downloaded file. This brings up the Python install wizard, which is really easy
to use. Just accept the default settings, wait until the install is finished, and you are done.
Macintosh Installation
Recent Macs come with Python installed, but it may be several years out of date. See
https://www.python.org/downloads/macos/ for instructions on getting the current version
along with extra tools to support development on the Mac. For older Mac OS's before Mac
OS X 10.3 (released in 2003), MacPython is available.
Jack Jansen maintains it and you can have full access to the entire documentation at his
website https://homepages.cwi.nl/~jack/macpython/index.html . You can find complete
installation details for Mac OS installation.

Setting up PATH
Programs and other executable files can be in many directories, so operating systems
provide a search path that lists the directories that the OS searches for executables.
The path is stored in an environment variable, which is a named string maintained by the operating
system. This variable contains information available to the command shell and other programs.
The path variable is named as PATH in Unix or Path in Windows (Unix is case sensitive; Windows
is not).
In Mac OS, the installer handles the path details. To invoke the Python interpreter from any
particular directory, you must add the Python directory to your path.
Setting path at Unix/Linux
To add the Python directory to the path for a particular session in Unix −
• In the csh shell − type setenv PATH "$PATH:/usr/local/bin/python" and press Enter.
• In the bash shell (Linux) − type export PATH="$PATH:/usr/local/bin/python" and press Enter.
• In the sh or ksh shell − type PATH="$PATH:/usr/local/bin/python" and press Enter.
• Note − /usr/local/bin/python is the path of the Python directory.
Setting path at Windows
To add the Python directory to the path for a particular session in Windows −
At the command prompt − type path %path%;C:\Python and press Enter.
Note − C:\Python is the path of the Python directory.
Running Python
There are three different ways to start Python −
Interactive Interpreter:
You can start Python from Unix, DOS, or any other system that provides you a
command-line interpreter or shell window.
Enter python the command line.
Start coding right away in the interactive interpreter.
$python # Unix/Linux
or
python% # Unix/Linux
or
C:> python # Windows/DOS

Script from the Command-line


A Python script can be executed at command line by invoking the interpreter on your
application, as in the following −
$python script.py # Unix/Linux
or
python% script.py # Unix/Linux
or
C: >python script.py # Windows/DOS
Integrated Development Environment
You can run Python from a Graphical User Interface (GUI) environment as well, if you have
a GUI application on your system that supports Python.
• Unix − IDLE is the very first Unix IDE for Python.
• Windows − PythonWin is the first Windows interface for Python and is an IDE with a
GUI.
• Macintosh − The Macintosh version of Python along with the IDLE IDE is available
from the main website, downloadable as either MacBinary or BinHex'd files.

You might also like