SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
Libraries
Prof. K. Adisesha
2
Learning objectives
• Understanding Library
• Importing Modules in Python Program
• Using Standard Library’s functions
• Creating a Python Library
3
What is a Library?
• A Library refers to a collection of modules that together
cater to specific types of needs or applications.
• Some Commonly used Python library are:
Library Functions
standard library This library is distributed with Python that contains modules for
various types of functionalities.
NumPy library This library provides some advance math functionalities along with
tools to create and manipulate numeric arrays.
SciPy library This is another useful library that offers algorithmic and
mathematical tools for scientific calculations.
tkinter library This library provides traditional Python user interface toolkit and
helps you to create user friendly GUI interface for different types
of applications.
Malplotlib library This library offers many functions and tools to produce quality
output in variety of formats such as plots, charts, graphs
4
Python standard library
• Some commonly used modules of Python standard library
are:
Library Functions
math module Provides mathematical functions to support different
types of calculations.
cmath module provides mathematical functions for complex numbers
random module provides functions for generating pseudo-random
numbers
statistics module provides mathematical statistics functions
Urllib module provides URL handling functions so that you can access
websites from within your program
5
What is a Module?
• Python module is a file(.py file) containing variables, class
definitions, statements and functions related to a particular task.
• A Module, in general:
 Is independent grouping of code and data
 Can be re-used in other programs.
 Can depend on other modules
6
Structure of a Python Module
• A Python module can contain much more than just functions.
• A Python module is a normal Python file (.py file) containing one or
more of the following objects related to a particular task:
• So, we can say that the module ‘ABC' means it is file ‘ABC.py’
Structure Task
docstrings triple quoted comments; useful for documentation purposes.
variables and
constants
labels for data
classes templates/blueprint to create objects of a certain kind
objects instances of classes. In general, objects are representation
of some real or abstract entity
statements Instructions for processing
functions named group of instructions
7
Importing Modules
• Python module files have an extension .py
• These modules can be imported in the following ways:
 import statement
- to import entire module
 from statement
- to import selected object
 from * statement
- import all names from the module
8
IMPORTING MODULES- import
• import statement is used to include the modules in other
programs.
 syntax : import <filename>
 example: import math
• more than one module can be inserted in a python program
 syntax : import <filename> ,<filename>,<filename>……
 example: import math,os
• using import statement one can view all the functions and
other attributes of a particular module
 example:
import math
dir(math)
9
IMPORTING MODULES- from
• importing module can be done using from statement
specific attributes can be included in other programs.
• syntax :
• from <filename> import function name
• example:
• from math import math.sqrt
10
IMPORTING MODULES- from*
• from* statement can be used to import all names from the
module in to the current calling name space.
• syntax :
from <filename> import *
• example:
from math import *
math.sqrt(4)
• we can access any function by using dot notation.
11
NAMESPACES
When we import modules in a particular program these modules will
become part of that program and are called as namespace.
Python implements namespaces in the form of dictionaries. It maintains a
name to object mapping.
There are three types of namespaces
1) Global
2) Local
3) Built in
Namespaces
12
MODULE ALIASING
• One can create an alias while importing module in a program
• Syntax:
import <filename> as <alias name>
• Example:
import math as m
m.sqrt(4)
• Like module aliasing members are also aliased
• syntax:
import <filename> as <alias name>,member as alias name
• Example:
import test as t, add as sum
test.py is module file and is referred to as t and add is the function,
it is referred to as sum.
13
PACKAGE/LIBRARY
• Python packages are the collection of related modules.
You can import a package or create your own.
• Python package is a simply directory of python modules
• Steps to create and import a package
1. create a directory named ‘Gemetry’
2. add modules area.py and volume.py
3. create a file __init__.py in directory ‘Geometry’. The __init__.py
files are required to make python treat the directory as containing
package
14
PACKAGE/LIBRARY
• What is __init__.py file?
• __init__.py is simply a file used to consider directories on the disk as
package of python.
• It is basically used to initilize the python package
• Python searches module in the following manner
• 1) Searches in current directory
• 2) If the module is not found then searches each directory in the shell variable
PYTHONPATH
• 3) If all else fails, python checks the default path which is the installation location
of the python
15
pip
• What is pip?
• pip is a package-management system used to install and manage
software packages written in Python.
• To check pip version run, pip --version at dos prompt
16
• We learned about the Python Library .
• Types of Libraries
• Modules in Python
• Packages in Python.
• We also looked at the creating PACKAGE/LIBRARY.
Thank you
Conclusion!

More Related Content

PPTX
Smart note taker
PPTX
Python Functions
PPTX
Functions in python slide share
PPTX
Python libraries for data science
PPTX
PDF
Python programming : Strings
PPT
Learn REST API with Python
PPTX
Ch1 introduction
Smart note taker
Python Functions
Functions in python slide share
Python libraries for data science
Python programming : Strings
Learn REST API with Python
Ch1 introduction

What's hot (20)

PDF
Python list
PPTX
Python: Modules and Packages
PPSX
Modules and packages in python
PPTX
Class, object and inheritance in python
PPTX
Chapter 05 classes and objects
PPTX
Dictionary in python
ODP
Python Modules
PPTX
Python Libraries and Modules
PDF
What is Python Lambda Function? Python Tutorial | Edureka
PDF
Set methods in python
PPTX
Chapter 03 python libraries
PDF
Arrays In Python | Python Array Operations | Edureka
PDF
Datatypes in python
PPTX
Python-Inheritance.pptx
PPTX
Tuple in python
PPTX
Functions in python
PPTX
Chapter 17 Tuples
PPT
Basic concept of OOP's
Python list
Python: Modules and Packages
Modules and packages in python
Class, object and inheritance in python
Chapter 05 classes and objects
Dictionary in python
Python Modules
Python Libraries and Modules
What is Python Lambda Function? Python Tutorial | Edureka
Set methods in python
Chapter 03 python libraries
Arrays In Python | Python Array Operations | Edureka
Datatypes in python
Python-Inheritance.pptx
Tuple in python
Functions in python
Chapter 17 Tuples
Basic concept of OOP's
Ad

Similar to Python libraries (20)

PDF
Using Python Libraries.pdf
PDF
Unit-2 Introduction of Modules and Packages.pdf
PPTX
Object oriented programming design and implementation
PPTX
Object oriented programming design and implementation
PPTX
AI - PYTHON PROGRAMMING BASICS II.pptx
PPTX
Class 12 CBSE Chapter: python libraries.pptx
PPTX
Python module 3, b.tech 5th semester ppt
PPTX
Using python libraries.pptx , easy ppt to study class 12
PPTX
Modules and Packages in Python Programming Language.pptx
PPTX
Interesting Presentation on Python Modules and packages
PPTX
Python Tutorial Part 2
PDF
Modules and Packages in Python_Basics.pdf
PPTX
Python Modules, executing modules as script.pptx
PDF
Python_AdvancedUnit - 3.pdf about the python
PPTX
CBSE-Class 12-Ch4 -Using Python Libraries - SasikalaJayaprakash
PPTX
FILE AND OBJECT<,ITS PROPERTIES IN PYTHON
PPTX
Functions_in_Python.pptx
PPTX
CLASS-11 & 12 ICT PPT Functions in Python.pptx
PDF
CLTL python course: Object Oriented Programming (2/3)
PPTX
jb_Modules_in_Python.pptx jb_Modules_in_Python.pptx
Using Python Libraries.pdf
Unit-2 Introduction of Modules and Packages.pdf
Object oriented programming design and implementation
Object oriented programming design and implementation
AI - PYTHON PROGRAMMING BASICS II.pptx
Class 12 CBSE Chapter: python libraries.pptx
Python module 3, b.tech 5th semester ppt
Using python libraries.pptx , easy ppt to study class 12
Modules and Packages in Python Programming Language.pptx
Interesting Presentation on Python Modules and packages
Python Tutorial Part 2
Modules and Packages in Python_Basics.pdf
Python Modules, executing modules as script.pptx
Python_AdvancedUnit - 3.pdf about the python
CBSE-Class 12-Ch4 -Using Python Libraries - SasikalaJayaprakash
FILE AND OBJECT<,ITS PROPERTIES IN PYTHON
Functions_in_Python.pptx
CLASS-11 & 12 ICT PPT Functions in Python.pptx
CLTL python course: Object Oriented Programming (2/3)
jb_Modules_in_Python.pptx jb_Modules_in_Python.pptx
Ad

More from Prof. Dr. K. Adisesha (20)

PDF
MACHINE LEARNING Notes by Dr. K. Adisesha
PDF
Probabilistic and Stochastic Models Unit-3-Adi.pdf
PDF
Genetic Algorithm in Machine Learning PPT by-Adi
PDF
Unsupervised Machine Learning PPT Adi.pdf
PDF
Supervised Machine Learning PPT by K. Adisesha
PDF
Introduction to Machine Learning PPT by K. Adisesha
PPSX
Design and Analysis of Algorithms ppt by K. Adi
PPSX
Data Structure using C by Dr. K Adisesha .ppsx
PDF
Operating System-4 "File Management" by Adi.pdf
PDF
Operating System-3 "Memory Management" by Adi.pdf
PDF
Operating System Concepts Part-1 by_Adi.pdf
PDF
Operating System-2_Process Managementby_Adi.pdf
PDF
Software Engineering notes by K. Adisesha.pdf
PDF
Software Engineering-Unit 1 by Adisesha.pdf
PDF
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
PDF
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
PDF
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
PDF
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
PDF
Computer Networks Notes by -Dr. K. Adisesha
PDF
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
MACHINE LEARNING Notes by Dr. K. Adisesha
Probabilistic and Stochastic Models Unit-3-Adi.pdf
Genetic Algorithm in Machine Learning PPT by-Adi
Unsupervised Machine Learning PPT Adi.pdf
Supervised Machine Learning PPT by K. Adisesha
Introduction to Machine Learning PPT by K. Adisesha
Design and Analysis of Algorithms ppt by K. Adi
Data Structure using C by Dr. K Adisesha .ppsx
Operating System-4 "File Management" by Adi.pdf
Operating System-3 "Memory Management" by Adi.pdf
Operating System Concepts Part-1 by_Adi.pdf
Operating System-2_Process Managementby_Adi.pdf
Software Engineering notes by K. Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Computer Networks Notes by -Dr. K. Adisesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha

Recently uploaded (20)

PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Institutional Correction lecture only . . .
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Business Ethics Teaching Materials for college
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
01-Introduction-to-Information-Management.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPH.pptx obstetrics and gynecology in nursing
Institutional Correction lecture only . . .
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Module 4: Burden of Disease Tutorial Slides S2 2025
Business Ethics Teaching Materials for college
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
01-Introduction-to-Information-Management.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Classroom Observation Tools for Teachers
Week 4 Term 3 Study Techniques revisited.pptx
O7-L3 Supply Chain Operations - ICLT Program
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Cell Types and Its function , kingdom of life
VCE English Exam - Section C Student Revision Booklet
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student

Python libraries

  • 2. 2 Learning objectives • Understanding Library • Importing Modules in Python Program • Using Standard Library’s functions • Creating a Python Library
  • 3. 3 What is a Library? • A Library refers to a collection of modules that together cater to specific types of needs or applications. • Some Commonly used Python library are: Library Functions standard library This library is distributed with Python that contains modules for various types of functionalities. NumPy library This library provides some advance math functionalities along with tools to create and manipulate numeric arrays. SciPy library This is another useful library that offers algorithmic and mathematical tools for scientific calculations. tkinter library This library provides traditional Python user interface toolkit and helps you to create user friendly GUI interface for different types of applications. Malplotlib library This library offers many functions and tools to produce quality output in variety of formats such as plots, charts, graphs
  • 4. 4 Python standard library • Some commonly used modules of Python standard library are: Library Functions math module Provides mathematical functions to support different types of calculations. cmath module provides mathematical functions for complex numbers random module provides functions for generating pseudo-random numbers statistics module provides mathematical statistics functions Urllib module provides URL handling functions so that you can access websites from within your program
  • 5. 5 What is a Module? • Python module is a file(.py file) containing variables, class definitions, statements and functions related to a particular task. • A Module, in general:  Is independent grouping of code and data  Can be re-used in other programs.  Can depend on other modules
  • 6. 6 Structure of a Python Module • A Python module can contain much more than just functions. • A Python module is a normal Python file (.py file) containing one or more of the following objects related to a particular task: • So, we can say that the module ‘ABC' means it is file ‘ABC.py’ Structure Task docstrings triple quoted comments; useful for documentation purposes. variables and constants labels for data classes templates/blueprint to create objects of a certain kind objects instances of classes. In general, objects are representation of some real or abstract entity statements Instructions for processing functions named group of instructions
  • 7. 7 Importing Modules • Python module files have an extension .py • These modules can be imported in the following ways:  import statement - to import entire module  from statement - to import selected object  from * statement - import all names from the module
  • 8. 8 IMPORTING MODULES- import • import statement is used to include the modules in other programs.  syntax : import <filename>  example: import math • more than one module can be inserted in a python program  syntax : import <filename> ,<filename>,<filename>……  example: import math,os • using import statement one can view all the functions and other attributes of a particular module  example: import math dir(math)
  • 9. 9 IMPORTING MODULES- from • importing module can be done using from statement specific attributes can be included in other programs. • syntax : • from <filename> import function name • example: • from math import math.sqrt
  • 10. 10 IMPORTING MODULES- from* • from* statement can be used to import all names from the module in to the current calling name space. • syntax : from <filename> import * • example: from math import * math.sqrt(4) • we can access any function by using dot notation.
  • 11. 11 NAMESPACES When we import modules in a particular program these modules will become part of that program and are called as namespace. Python implements namespaces in the form of dictionaries. It maintains a name to object mapping. There are three types of namespaces 1) Global 2) Local 3) Built in Namespaces
  • 12. 12 MODULE ALIASING • One can create an alias while importing module in a program • Syntax: import <filename> as <alias name> • Example: import math as m m.sqrt(4) • Like module aliasing members are also aliased • syntax: import <filename> as <alias name>,member as alias name • Example: import test as t, add as sum test.py is module file and is referred to as t and add is the function, it is referred to as sum.
  • 13. 13 PACKAGE/LIBRARY • Python packages are the collection of related modules. You can import a package or create your own. • Python package is a simply directory of python modules • Steps to create and import a package 1. create a directory named ‘Gemetry’ 2. add modules area.py and volume.py 3. create a file __init__.py in directory ‘Geometry’. The __init__.py files are required to make python treat the directory as containing package
  • 14. 14 PACKAGE/LIBRARY • What is __init__.py file? • __init__.py is simply a file used to consider directories on the disk as package of python. • It is basically used to initilize the python package • Python searches module in the following manner • 1) Searches in current directory • 2) If the module is not found then searches each directory in the shell variable PYTHONPATH • 3) If all else fails, python checks the default path which is the installation location of the python
  • 15. 15 pip • What is pip? • pip is a package-management system used to install and manage software packages written in Python. • To check pip version run, pip --version at dos prompt
  • 16. 16 • We learned about the Python Library . • Types of Libraries • Modules in Python • Packages in Python. • We also looked at the creating PACKAGE/LIBRARY. Thank you Conclusion!