SlideShare a Scribd company logo
Python Library
and Modules
A library is a collection of modules. It is a reusable
chunk of code that you may want to include in
your programs/projects.
pyttsx3
wikipedia
Pandas
Nampy
Some python
libraries are:-
Numpy is considered as one of the most popular
machine learning library in Python. Array interface is
the best and the most important feature of Numpy. This
interface can be utilized for expressing images, sound
waves, and other binary raw streams as an array of real
numbers in N-dimensional.
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(arr)
print(type(arr))
Output- [1 2 3 4 5]
<class 'numpy.ndarray'>
Example 1-
import numpy as np
arr = np.array([[1, 2, 3], [4, 5, 6]])
print(arr)
Output- [[1 2 3]
[4 5 6]]
Example 2-
Pandas is a Python library used for working with data
sets. It has functions for analyzing, cleaning, exploring,
and manipulating data. Its allows us to analyze big
data and make conclusions based on statistical
theories. It can clean messy data sets, and make them
readable and relevant.
import pandas as pd
data = {'Name':[' Janny ', 'Amit',’Suji‘]
'Age':[28,34,29,42]}
df = pd.DataFrame(data)
print df
Its output is as follows −
Age Name
0 28 Janny
1 34 Amit
2 29 Suji
Example1
pyttsx3 is a text-to-speech conversion library in Python.
Unlike alternative libraries, it works offline.
import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()
Wikipedia is a Python library that makes it easy to
access and parse data from Wikipedia. Search
Wikipedia, get article summaries, get data like links
and images from a page, and more.
Example1
import wikipedia
# finding result for the search
# sentences = 2 refers to numbers of line
result = wikipedia.summary("India", sentences = 2)
# printing the result
print(result)
A python module can be defined as a python
program file which contains a python code
including python functions, class, or variables.
In other words, we can say that our python
code file saved with the extension (.py) is
treated as the module.
Python Modules
Some Python Modules are:-
datetime
1
webbrowser
2
OS
3
Tkinter
4
random
5
The datetime module supplies classes for
manipulating dates and times. The datetime module
has many methods to return information about the
date object.
datetime
import datetime
x = datetime.datetime.now()
print(x.year)
print(x.strftime("%A"))
Output-2021
Sunday
15
Example- Return the year and name of weekday
The webbrowser module includes functions to open
URLs in interactive browser applications. The module
includes a registry of available browsers, in case
multiple options are available on the system. It can also
be controlled with the BROWSER environment variable.
webbrowser
import webbrowser
webbrowser.open('http://docs.python.org/lib/module-webbrowser.html')
Example-
To open a page in the browser, we use
open() function.
The OS module in Python provides functions for
interacting with the operating system. OS comes under
Python’s standard utility modules. This module provides
a portable way of using operating system-dependent
functionality.
OS
1. os.remove() - os.remove() method in Python is used to
remove or delete a file path. This method can not remove
or delete a directory.
2. os.mkdir() - os.mkdir() method in Python is used to create
a directory named path with the specified numeric mode.
The *os* and *os.path* modules include many
functions to interact with the file system. Some
functions are-
3. os.listdir()- os.listdir() method in Python is
used to get the list of all files and
directories in the specified directory. If we
don’t specify any directory, then list of files
and directories in the current working
directory will be returned.
Tkinter is a graphical user interface (GUI) module
for Python, you can make desktop apps with Python
and can develop GUI applications like calculator,
login system, text editor, etc.
Tkinter
Tkinter provides various controls, such as buttons,
labels and text boxes used in a GUI application.
These controls are commonly called widgets.
Tkinter Widgets
Important method of Tkinter
This method is used to start the application.
The mainloop() function is an infinite loop which is used to
run the application, it will wait for an event to
occur and process the event as long as the window is not
closed.
2. The mainloop() Function:-
This method is mainly used to create the main window.
1. Tk(screenName=None, baseName=None, className='Tk', useTk=1) :-
Random
The random module is a built-in module to
generate the pseudo random variables. It can
be used to perform some action randomly
such as to get a random number, selecting a
random elements from a list, shuffle elements
randomly, etc.
Method of Random
seed()- It initialize the random number generator.
getstate()- It returns the current internal state of
the random number generator.
setstate()- It restores the internal state of the
random number generator.
Method of Random
choices()- It returns a list with a element from the
given sequence.
randint()- It returns a random number between the
given range.
For more presentation
contact us
raginijain0208@gmail.com
Python Libraries and Modules

More Related Content

PPSX
Modules and packages in python
PPTX
Chapter 03 python libraries
PDF
Python libraries
ODP
Python Modules
PPTX
Python OOPs
PDF
Python programming : Files
PPSX
python Function
PDF
Python functions
Modules and packages in python
Chapter 03 python libraries
Python libraries
Python Modules
Python OOPs
Python programming : Files
python Function
Python functions

What's hot (20)

PPTX
Python Functions
PDF
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
PPTX
Python: Polymorphism
PPT
1.python interpreter and interactive mode
PPS
Wrapper class
PDF
Datatypes in python
PPTX
Python-Inheritance.pptx
PDF
Introduction to NumPy (PyData SV 2013)
PPTX
Chapter 05 classes and objects
PPTX
Introduction to python
PDF
What is Python Lambda Function? Python Tutorial | Edureka
PPTX
Class, object and inheritance in python
PPTX
Packages In Python Tutorial
PPTX
Regular expressions in Python
PDF
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
PPTX
Python: Modules and Packages
PDF
Python Basics | Python Tutorial | Edureka
PDF
Class and Objects in Java
PPTX
Basics of Object Oriented Programming in Python
PPT
Basic concept of OOP's
Python Functions
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python: Polymorphism
1.python interpreter and interactive mode
Wrapper class
Datatypes in python
Python-Inheritance.pptx
Introduction to NumPy (PyData SV 2013)
Chapter 05 classes and objects
Introduction to python
What is Python Lambda Function? Python Tutorial | Edureka
Class, object and inheritance in python
Packages In Python Tutorial
Regular expressions in Python
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
Python: Modules and Packages
Python Basics | Python Tutorial | Edureka
Class and Objects in Java
Basics of Object Oriented Programming in Python
Basic concept of OOP's
Ad

Similar to Python Libraries and Modules (20)

PPTX
libraries in python using different .pptx
DOCX
pythonlibrariesandmodules-210530042906.docx
PDF
summer training report on python
PDF
Python. libraries. modules. and. all.pdf
PPTX
Python for Beginners
PPTX
Introduction to Python programming Language
ODP
Programming Under Linux In Python
PDF
class 12 Libraries in dfbdsbsdbdfbdfdfdf.pdf
PDF
W-334535VBE242 Using Python Libraries.pdf
PDF
Using Python Libraries.pdf
PPTX
Introduction to Python for Security Professionals
PPTX
Class 12 CBSE Chapter: python libraries.pptx
PPTX
Introduction-to-Python-for-better-knowledge-
PPTX
Government Polytechnic Arvi-1.pptx
PPTX
Shivam PPT.pptx
PPTX
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
PPTX
Python Demo.pptx
PDF
Python Viva Interview Questions PDF By ScholarHat
PPTX
Complete Core Python with IPT Excel School
PPTX
Python Demo.pptx
libraries in python using different .pptx
pythonlibrariesandmodules-210530042906.docx
summer training report on python
Python. libraries. modules. and. all.pdf
Python for Beginners
Introduction to Python programming Language
Programming Under Linux In Python
class 12 Libraries in dfbdsbsdbdfbdfdfdf.pdf
W-334535VBE242 Using Python Libraries.pdf
Using Python Libraries.pdf
Introduction to Python for Security Professionals
Class 12 CBSE Chapter: python libraries.pptx
Introduction-to-Python-for-better-knowledge-
Government Polytechnic Arvi-1.pptx
Shivam PPT.pptx
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
Python Demo.pptx
Python Viva Interview Questions PDF By ScholarHat
Complete Core Python with IPT Excel School
Python Demo.pptx
Ad

More from RaginiJain21 (8)

PPTX
Jump statment in python
PPTX
Looping statement in python
PPTX
Conditionalstatement
PPTX
Python media library
PPTX
Basic python programs
PPTX
Data types in python
PPTX
Python second ppt
PPTX
Final presentation on python
Jump statment in python
Looping statement in python
Conditionalstatement
Python media library
Basic python programs
Data types in python
Python second ppt
Final presentation on python

Recently uploaded (20)

PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Structure & Organelles in detailed.
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
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 Đ...
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Institutional Correction lecture only . . .
PDF
Pre independence Education in Inndia.pdf
TR - Agricultural Crops Production NC III.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Pharma ospi slides which help in ospi learning
Cell Structure & Organelles in detailed.
Microbial disease of the cardiovascular and lymphatic systems
human mycosis Human fungal infections are called human mycosis..pptx
STATICS OF THE RIGID BODIES Hibbelers.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 Đ...
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
FourierSeries-QuestionsWithAnswers(Part-A).pdf
RMMM.pdf make it easy to upload and study
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Abdominal Access Techniques with Prof. Dr. R K Mishra
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Institutional Correction lecture only . . .
Pre independence Education in Inndia.pdf

Python Libraries and Modules

  • 2. A library is a collection of modules. It is a reusable chunk of code that you may want to include in your programs/projects.
  • 4. Numpy is considered as one of the most popular machine learning library in Python. Array interface is the best and the most important feature of Numpy. This interface can be utilized for expressing images, sound waves, and other binary raw streams as an array of real numbers in N-dimensional.
  • 5. import numpy as np arr = np.array([1, 2, 3, 4, 5]) print(arr) print(type(arr)) Output- [1 2 3 4 5] <class 'numpy.ndarray'> Example 1-
  • 6. import numpy as np arr = np.array([[1, 2, 3], [4, 5, 6]]) print(arr) Output- [[1 2 3] [4 5 6]] Example 2-
  • 7. Pandas is a Python library used for working with data sets. It has functions for analyzing, cleaning, exploring, and manipulating data. Its allows us to analyze big data and make conclusions based on statistical theories. It can clean messy data sets, and make them readable and relevant.
  • 8. import pandas as pd data = {'Name':[' Janny ', 'Amit',’Suji‘] 'Age':[28,34,29,42]} df = pd.DataFrame(data) print df Its output is as follows − Age Name 0 28 Janny 1 34 Amit 2 29 Suji Example1
  • 9. pyttsx3 is a text-to-speech conversion library in Python. Unlike alternative libraries, it works offline. import pyttsx3 engine = pyttsx3.init() engine.say("I will speak this text") engine.runAndWait()
  • 10. Wikipedia is a Python library that makes it easy to access and parse data from Wikipedia. Search Wikipedia, get article summaries, get data like links and images from a page, and more.
  • 11. Example1 import wikipedia # finding result for the search # sentences = 2 refers to numbers of line result = wikipedia.summary("India", sentences = 2) # printing the result print(result)
  • 12. A python module can be defined as a python program file which contains a python code including python functions, class, or variables. In other words, we can say that our python code file saved with the extension (.py) is treated as the module. Python Modules
  • 13. Some Python Modules are:- datetime 1 webbrowser 2 OS 3 Tkinter 4 random 5
  • 14. The datetime module supplies classes for manipulating dates and times. The datetime module has many methods to return information about the date object. datetime
  • 15. import datetime x = datetime.datetime.now() print(x.year) print(x.strftime("%A")) Output-2021 Sunday 15 Example- Return the year and name of weekday
  • 16. The webbrowser module includes functions to open URLs in interactive browser applications. The module includes a registry of available browsers, in case multiple options are available on the system. It can also be controlled with the BROWSER environment variable. webbrowser
  • 18. The OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system-dependent functionality. OS
  • 19. 1. os.remove() - os.remove() method in Python is used to remove or delete a file path. This method can not remove or delete a directory. 2. os.mkdir() - os.mkdir() method in Python is used to create a directory named path with the specified numeric mode. The *os* and *os.path* modules include many functions to interact with the file system. Some functions are-
  • 20. 3. os.listdir()- os.listdir() method in Python is used to get the list of all files and directories in the specified directory. If we don’t specify any directory, then list of files and directories in the current working directory will be returned.
  • 21. Tkinter is a graphical user interface (GUI) module for Python, you can make desktop apps with Python and can develop GUI applications like calculator, login system, text editor, etc. Tkinter
  • 22. Tkinter provides various controls, such as buttons, labels and text boxes used in a GUI application. These controls are commonly called widgets. Tkinter Widgets
  • 23. Important method of Tkinter This method is used to start the application. The mainloop() function is an infinite loop which is used to run the application, it will wait for an event to occur and process the event as long as the window is not closed. 2. The mainloop() Function:- This method is mainly used to create the main window. 1. Tk(screenName=None, baseName=None, className='Tk', useTk=1) :-
  • 24. Random The random module is a built-in module to generate the pseudo random variables. It can be used to perform some action randomly such as to get a random number, selecting a random elements from a list, shuffle elements randomly, etc.
  • 25. Method of Random seed()- It initialize the random number generator. getstate()- It returns the current internal state of the random number generator. setstate()- It restores the internal state of the random number generator.
  • 26. Method of Random choices()- It returns a list with a element from the given sequence. randint()- It returns a random number between the given range.
  • 27. For more presentation contact us raginijain0208@gmail.com