Python Libraries
A N O V E RV I E W
Introduction
• Python library is a collection of Python
modules that provide specific functionality.
• Can be used for a wide variety of tasks, such
as web development, data science, machine
learning, and more.
• Defined to provide a common set of functions
and classes that can be used by Python
programmers.
• makes it easier for programmers to write code,
as they do not have to reinvent the wheel
every time, they need to perform a common
task.
Types of libraries
• Standard library: The standard library is a set of libraries that is
included with the Python installation.
• Third-party libraries: Third-party libraries are libraries that are not
included with the Python installation. They can be installed from the
Python Package Index (PyPI) or from other sources. There are
thousands of third-party libraries available, and they provide a wide
range of functionality, such as web frameworks, data science
libraries, and machine learning libraries.
Reasons
• To provide a common set of functions and classes that can be used by Python
programmers. This makes it easier for programmers to write code, as they do not
have to reinvent the wheel every time, they need to perform a common task.
• To promote code reuse. Python libraries can be used to share functionality
between different Python programs. This can save programmers time and effort.
• To encourage standardization. Python libraries can be used to ensure that
different Python programs use the same terminology and conventions. This can
make it easier to read and understand Python code.
• To provide a platform for innovation. Python libraries can be used to develop
new and innovative software. For example, the NumPy and SciPy libraries have
been used to develop many popular data science and machine learning tools.
Common Libraries
• os: This module provides functions for interacting with the operating
system, such as opening and closing files, creating and deleting
directories, and running processes.
• socket: This module provides functions for creating and using
network sockets.
• datetime: This module provides functions for working with dates and
times.
• subprocess: This module provides functions for running external
programs.
• math: This module provides mathematical functions, such as
trigonometry, statistics, and random number generation.
How to use
Tips for using Libraries
• Start by reading the library's documentation. This will help you to
understand the library's functionality and how to use it.
• Use the library's API reference. This will give you a list of all of the
functions and classes that the library provides.
• Look for examples of how to use the library. There are many examples
available online and in the library's documentation.
• Experiment with the library. The best way to learn how to use a
library is to experiment with it. Write some simple code to test the
library's functionality.
Third-Party Libraries
• NumPy: NumPy is a library for scientific computing with Python. It provides a high-
performance multidimensional array object, and a collection of routines for working with
such arrays, including mathematical functions, logical functions, sorting, searching, and
linear algebra.
• SciPy: SciPy is a library for scientific computing with Python. It builds on NumPy and
provides a wide range of functions for scientific and engineering computations, including
signal processing, image processing, optimization, statistics, and more.
• Matplotlib: Matplotlib is a library for creating data visualizations in Python. It provides a
wide range of plotting capabilities, including line plots, bar charts, histograms, scatter
plots, and 3D plots.
• Pandas: Pandas is a library for data manipulation and analysis in Python. It provides data
structures and functions for working with structured (tabular) and time-series data.
• TensorFlow: TensorFlow is a library for machine learning in Python. It provides a high-
level API for creating and training machine learning models.
Third-Party Libraries
• PyTorch: PyTorch is a library for machine learning in Python. It provides a low-
level API for creating and training machine learning models.
• Requests: Requests is a library for making HTTP requests in Python. It is a
popular choice for making web API calls.
• BeautifulSoup: BeautifulSoup is a library for parsing HTML and XML documents
in Python. It is a popular choice for web scraping.
• Flask: Flask is a lightweight web framework for Python. It is a good choice for
building simple and RESTful web applications.
• Django: Django is a full-stack web framework for Python. It is a good choice for
building complex web applications.
• Celery: Celery is a task queue for Python. It is a good choice for processing
asynchronous tasks.