CHAPTER - 03
PYTHON LIBRARIES
Unit I
Programming and Computational
Thinking (PCT-2)
(80 Theory + 70 Practical)
DCSc & Engg, PGDCA,ADCA,MCA.MSc(IT),Mtech(IT),MPhil (Comp. Sci)
Department of Computer Science, Sainik School Amaravathinagar
Cell No: 9431453730
Praveen M Jigajinni
Prepared by
Courtesy CBSE
Class XII
INTRODUCTION
INTRODUCTION
A Module is a file containing python definitions,
functions, variables, classes and statements with .py
extension.
Python package is a directory of python module.
A Library is a collection of various packages.
There is no difference between library and python
package. Library is used to loosely describe a
collection of core or main modules.
COMPONENTS OF PYTHON PROGRAM
COMPONENTS OF PYTHON PROGRAM
A Module is a file that contains python code.
The python program comprises of three main
components
i) Library or Package
ii) Module
iii) Functions/Sub-Modules
ADVANTAGES OF MODULES
ADVANTAGES OF MODULES
1. Reusability
2. Clarity
3. Classification/ Grouping of code
4. Easy to understand
IMPORTING MODULES
IMPORTING MODULES
t
Python module files have an extension .py
These modules can be imported in the following
ways:
1) import statement
2) from statement
3) from * statement
IMPORTING MODULES- import
t
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>……..
for example: import math,os
IMPORTING MODULES- import
t
using import statement one can view all the
functions and other attributes of a particular
module
for example: import math
dir(math)
IMPORTING MODULES- import
IMPORTING MODULES- from
t
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
IMPORTING MODULES- from*
t
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.
NAMESPACES
NAMESPACES
t
When we import modules in a particular
program these modules will become part of that
program and are called as namespace.
Python impliments 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
Built in name space
Global name space
Local name
space
NAME RESOLUTION
NAME RESOLUTION
t9lo
Already we know the scope rules of python
programming.
For every name reference within a
program when you access a variable python follows
name resolution rule i.e LEGB (Local, Enclosed,
Global, Built-in)
Contd.. Next slide
NAME RESOLUTION
Built in name space
Global name space
Local name space
Enclosed
MODULE ALIASING
MODULE ALIASING
t9lo
One can create an alias while importing module
in a program
syntax:
import <filename> as <alias name>
for example: import math as m
m.sqrt(4)
MEMBER ALIASING
MEMBER ALIASING
t9lo
Like module aliasing members are also aliased
syntax:
import <filename> as <alias name>,
member as alias name
for 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.
PACKAGE/LIBRARY
PACKAGE/LIBRARY
t9lo
Python packages are the collection of related
modules. You can import a package or create your
own.
The main difference between a module
and a package is that package is a
collection of modules and has an
__init__.py file
PACKAGE/LIBRARY
t9lo
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
PACKAGE/LIBRARY
GEOMETRY
Area.py Volume.py
FOLDER
FILES
PACKAGE/LIBRARY
FOLDER IS CREATED
PACKAGE/LIBRARY
AREA MODULE IS CREATED
PACKAGE/LIBRARY
VOLUME MODULE IS CREATED
PACKAGE/LIBRARY
CREATING __init__.py FILE
PACKAGE/LIBRARY
__init__.py FILE
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
LOCATING MODULES
PACKAGE/LIBRARY
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
PACKAGE/LIBRARY
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
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
PYTHON STANDARD LIBRARY
PYTHON STANDARD LIBRARY
DATE AND TIME MODULE.
import datetime
v_date=datetime.date.today()
vyear = v_date.year()
vmonth = v_date.month()
vday = v_date.day()
PYTHON STANDARD LIBRARY
DATE AND TIME MODULE.
import datetime
v_date=datetime.date.today()
vnow = v_date.now()
vhour = v_date.hour()
vmin = v_date.minute()
vsec = v_date.second()
CLASS TEST
1. What are the components of python program.
2.Explain the ways to import a module in
python program.
3.What is namespace? Explain in detail
4. What is python package? Write down the
steps to create a python package and also write
a programs and create a package.
Class : XII Time: 40 Min
Topic: Python Libraries Max Marks: 40
Each Question carries 5 Marks
Thank You

More Related Content

PPTX
Chapter 13 exceptional handling
PPTX
Chapter 8 getting started with python
PPTX
Chapter 15 Lists
PDF
Python libraries
PPTX
Data types in python
PPTX
Experiential learning
PPTX
Data Structures in Python
PPTX
Chapter 05 classes and objects
Chapter 13 exceptional handling
Chapter 8 getting started with python
Chapter 15 Lists
Python libraries
Data types in python
Experiential learning
Data Structures in Python
Chapter 05 classes and objects

What's hot (20)

PPTX
Python: Modules and Packages
PDF
Python GUI
PPTX
Packages In Python Tutorial
PPTX
Python Functions
PDF
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
PPTX
File handling in Python
PDF
Python File Handling | File Operations in Python | Learn python programming |...
PPTX
Datastructures in python
PDF
Functions and modules in python
PDF
Python programming : Classes objects
PPTX
11 Unit1 Chapter 1 Getting Started With Python
PPTX
Python Libraries and Modules
PPTX
Iterarators and generators in python
PPSX
Programming with Python
PPTX
List in Python
PPTX
Chapter 07 inheritance
PPTX
Python 101: Python for Absolute Beginners (PyTexas 2014)
PDF
Python basic
PPT
Python GUI Programming
PPTX
Looping statement in python
Python: Modules and Packages
Python GUI
Packages In Python Tutorial
Python Functions
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
File handling in Python
Python File Handling | File Operations in Python | Learn python programming |...
Datastructures in python
Functions and modules in python
Python programming : Classes objects
11 Unit1 Chapter 1 Getting Started With Python
Python Libraries and Modules
Iterarators and generators in python
Programming with Python
List in Python
Chapter 07 inheritance
Python 101: Python for Absolute Beginners (PyTexas 2014)
Python basic
Python GUI Programming
Looping statement in python
Ad

Similar to Chapter 03 python libraries (20)

PDF
Using Python Libraries.pdf
PPTX
Using python libraries.pptx , easy ppt to study class 12
PDF
Python_AdvancedUnit - 3.pdf about the python
PDF
Python modules
PPTX
Python Session - 5
PPTX
packages.pptx
PPTX
Python module 3, b.tech 5th semester ppt
PPTX
Python Modules, executing modules as script.pptx
ODP
Pythonpresent
PDF
Python. libraries. modules. and. all.pdf
PPTX
python interview based12345672342 234234 213123 423423
PPTX
52 Python Question Answers.pptx 12434ddsda2eqweqw
PPT
Python modules
PPTX
Modules,Packages,Librarfrserrrrrrrrrrrries.pptx
PPT
mod.ppt mod.ppt mod.ppt mod.ppt mod.pp d
PPTX
Object oriented programming design and implementation
PPTX
Object oriented programming design and implementation
PDF
python interview prep question , 52 questions
PDF
Modules and Packages in Python_Basics.pdf
Using Python Libraries.pdf
Using python libraries.pptx , easy ppt to study class 12
Python_AdvancedUnit - 3.pdf about the python
Python modules
Python Session - 5
packages.pptx
Python module 3, b.tech 5th semester ppt
Python Modules, executing modules as script.pptx
Pythonpresent
Python. libraries. modules. and. all.pdf
python interview based12345672342 234234 213123 423423
52 Python Question Answers.pptx 12434ddsda2eqweqw
Python modules
Modules,Packages,Librarfrserrrrrrrrrrrries.pptx
mod.ppt mod.ppt mod.ppt mod.ppt mod.pp d
Object oriented programming design and implementation
Object oriented programming design and implementation
python interview prep question , 52 questions
Modules and Packages in Python_Basics.pdf
Ad

More from Praveen M Jigajinni (20)

PPTX
Chapter 09 design and analysis of algorithms
PPTX
Chapter 08 data file handling
PPTX
Chapter 06 constructors and destructors
PPTX
Chapter 04 object oriented programming
PPTX
Chapter 02 functions -class xii
PPTX
Unit 3 MongDB
PPTX
Chapter 17 Tuples
PPTX
Chapter 14 strings
PPTX
Chapter 10 data handling
PPTX
Chapter 9 python fundamentals
PPTX
Chapter 7 basics of computational thinking
PPTX
Chapter 6 algorithms and flow charts
PPTX
Chapter 5 boolean algebra
PPTX
Chapter 4 number system
PPTX
Chapter 3 cloud computing and intro parrallel computing
PPTX
Chapter 2 operating systems
PPTX
Chapter 1 computer fundamentals
PPT
Chapter 0 syllabus 2019 20
PPTX
Chapter 16 Dictionaries
PPTX
11 Unit 1 Problem Solving Techniques
Chapter 09 design and analysis of algorithms
Chapter 08 data file handling
Chapter 06 constructors and destructors
Chapter 04 object oriented programming
Chapter 02 functions -class xii
Unit 3 MongDB
Chapter 17 Tuples
Chapter 14 strings
Chapter 10 data handling
Chapter 9 python fundamentals
Chapter 7 basics of computational thinking
Chapter 6 algorithms and flow charts
Chapter 5 boolean algebra
Chapter 4 number system
Chapter 3 cloud computing and intro parrallel computing
Chapter 2 operating systems
Chapter 1 computer fundamentals
Chapter 0 syllabus 2019 20
Chapter 16 Dictionaries
11 Unit 1 Problem Solving Techniques

Recently uploaded (20)

PDF
Unleashing the Potential of the Cultural and creative industries
PPTX
ENGlishGrade8_Quarter2_WEEK1_LESSON1.pptx
PPTX
Juvenile delinquency-Crim Research day 3x
PDF
Teacher's Day Quiz 2025
PDF
Design and Evaluation of a Inonotus obliquus-AgNP-Maltodextrin Delivery Syste...
PDF
BA-1ST(Education)-Education and Society.pdf
PPTX
Unit1_Kumod_deeplearning.pptx DEEP LEARNING
PDF
BA-1ST(Education)-Education and Society.pdf
PDF
Bacterial Diversity and Evolution Bacterial Taxonomy Lecture (4)_.pdf
PPTX
CHF refers to the condition wherein heart unable to pump a sufficient amount ...
PPTX
UCSP Section A - Human Cultural Variations,Social Differences,social ChangeCo...
PDF
horaris de grups del curs 2025-2026 de l'institut
PPTX
macro complete discussion with given activities
PPTX
Power of Gratitude: Honouring our teachers
PDF
English 2nd semesteNotesh biology biopsy results from the other day and I jus...
PDF
NGÂN HÀNG CÂU HỎI TÁCH CHỌN LỌC THEO CHUYÊN ĐỀ TỪ ĐỀ THI THỬ TN THPT 2025 TIẾ...
PPTX
FILIPINO 8 Q2 WEEK 1(DAY 1).power point presentation
PDF
The 10 Most Inspiring Education Leaders to Follow in 2025.pdf
PPTX
Environmental Sciences and Sustainability Chapter 2
Unleashing the Potential of the Cultural and creative industries
ENGlishGrade8_Quarter2_WEEK1_LESSON1.pptx
Juvenile delinquency-Crim Research day 3x
Teacher's Day Quiz 2025
Design and Evaluation of a Inonotus obliquus-AgNP-Maltodextrin Delivery Syste...
BA-1ST(Education)-Education and Society.pdf
Unit1_Kumod_deeplearning.pptx DEEP LEARNING
BA-1ST(Education)-Education and Society.pdf
Bacterial Diversity and Evolution Bacterial Taxonomy Lecture (4)_.pdf
CHF refers to the condition wherein heart unable to pump a sufficient amount ...
UCSP Section A - Human Cultural Variations,Social Differences,social ChangeCo...
horaris de grups del curs 2025-2026 de l'institut
macro complete discussion with given activities
Power of Gratitude: Honouring our teachers
English 2nd semesteNotesh biology biopsy results from the other day and I jus...
NGÂN HÀNG CÂU HỎI TÁCH CHỌN LỌC THEO CHUYÊN ĐỀ TỪ ĐỀ THI THỬ TN THPT 2025 TIẾ...
FILIPINO 8 Q2 WEEK 1(DAY 1).power point presentation
The 10 Most Inspiring Education Leaders to Follow in 2025.pdf
Environmental Sciences and Sustainability Chapter 2

Chapter 03 python libraries

  • 2. Unit I Programming and Computational Thinking (PCT-2) (80 Theory + 70 Practical) DCSc & Engg, PGDCA,ADCA,MCA.MSc(IT),Mtech(IT),MPhil (Comp. Sci) Department of Computer Science, Sainik School Amaravathinagar Cell No: 9431453730 Praveen M Jigajinni Prepared by Courtesy CBSE Class XII
  • 4. INTRODUCTION A Module is a file containing python definitions, functions, variables, classes and statements with .py extension. Python package is a directory of python module. A Library is a collection of various packages. There is no difference between library and python package. Library is used to loosely describe a collection of core or main modules.
  • 6. COMPONENTS OF PYTHON PROGRAM A Module is a file that contains python code. The python program comprises of three main components i) Library or Package ii) Module iii) Functions/Sub-Modules
  • 8. ADVANTAGES OF MODULES 1. Reusability 2. Clarity 3. Classification/ Grouping of code 4. Easy to understand
  • 10. IMPORTING MODULES t Python module files have an extension .py These modules can be imported in the following ways: 1) import statement 2) from statement 3) from * statement
  • 11. IMPORTING MODULES- import t 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>…….. for example: import math,os
  • 12. IMPORTING MODULES- import t using import statement one can view all the functions and other attributes of a particular module for example: import math dir(math)
  • 14. IMPORTING MODULES- from t 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
  • 15. IMPORTING MODULES- from* t 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.
  • 17. NAMESPACES t When we import modules in a particular program these modules will become part of that program and are called as namespace. Python impliments 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
  • 18. NAMESPACES Built in name space Global name space Local name space
  • 20. NAME RESOLUTION t9lo Already we know the scope rules of python programming. For every name reference within a program when you access a variable python follows name resolution rule i.e LEGB (Local, Enclosed, Global, Built-in) Contd.. Next slide
  • 21. NAME RESOLUTION Built in name space Global name space Local name space Enclosed
  • 23. MODULE ALIASING t9lo One can create an alias while importing module in a program syntax: import <filename> as <alias name> for example: import math as m m.sqrt(4)
  • 25. MEMBER ALIASING t9lo Like module aliasing members are also aliased syntax: import <filename> as <alias name>, member as alias name for 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.
  • 27. PACKAGE/LIBRARY t9lo Python packages are the collection of related modules. You can import a package or create your own. The main difference between a module and a package is that package is a collection of modules and has an __init__.py file
  • 28. PACKAGE/LIBRARY t9lo 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
  • 34. PACKAGE/LIBRARY __init__.py FILE 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
  • 36. PACKAGE/LIBRARY 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
  • 37. PACKAGE/LIBRARY 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
  • 38. pip
  • 39. 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
  • 41. PYTHON STANDARD LIBRARY DATE AND TIME MODULE. import datetime v_date=datetime.date.today() vyear = v_date.year() vmonth = v_date.month() vday = v_date.day()
  • 42. PYTHON STANDARD LIBRARY DATE AND TIME MODULE. import datetime v_date=datetime.date.today() vnow = v_date.now() vhour = v_date.hour() vmin = v_date.minute() vsec = v_date.second()
  • 43. CLASS TEST 1. What are the components of python program. 2.Explain the ways to import a module in python program. 3.What is namespace? Explain in detail 4. What is python package? Write down the steps to create a python package and also write a programs and create a package. Class : XII Time: 40 Min Topic: Python Libraries Max Marks: 40 Each Question carries 5 Marks