KEMBAR78
libraries in python using different .pptx
Python Library
and Modules
Python Library
A library is a collection of modules. It is a reusable chunk of
code that you may want to include in your programs/projects.
Python offers a vast array of libraries to cater to different
needs, ranging from general programming to specialized fields
like data science, machine learning, web development, and
more. Below is a categorized overview:
pyttsx
3
wikipedi
a
Pandas
Numpy
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.
Numpy
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.
Data manipulation and analysis
Provides DataFrames for structured data operations.s
Pandas
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()
Pyttsx3
Wikipedia
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
A Module is a file containing document
and statement
provide proper organization
code reusability
namespace management
encapsulation
13
Some Python Modules are:-
datetime
1
webbrowser
2
OS
3
Tkinter
4
random
5
General-Purpose Libraries
os: For interacting with the operating system (e.g., file handling, environment variables)
sys: Access system-specific parameters and functions
re: Regular expressions for pattern matching and text processing
datetime: For handling date and time
math: Provides mathematical functions like trigonometry, logarithms, etc
15
datetime
The datetime module supplies classes for
manipulating dates and times.
The datetime module has many methods to
return information about the date object.
import datetime
x = datetime.datetime.now()
print(x.year)
print(x.strftime("%A"))
Output-2021
Sunday
17
Example- Return the year and name of weekday
webbrowser
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.
Example-
import webbrowser
webbrowser.open('http://docs.python.org/lib/module-webbrowser.html')
To open a page in the browser, we use
open() function.
OS
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.
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
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 Widgets
Tkinter provides various controls, such as
buttons, labels and text boxes used in a GUI
application. These controls are commonly
called 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.
The mainloop() Function:-
This method is mainly used to create the main window.
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
libraries in python using different .pptx

libraries in python using different .pptx

  • 1.
  • 2.
    Python Library A libraryis a collection of modules. It is a reusable chunk of code that you may want to include in your programs/projects. Python offers a vast array of libraries to cater to different needs, ranging from general programming to specialized fields like data science, machine learning, web development, and more. Below is a categorized overview:
  • 3.
  • 4.
    Numpy is consideredas 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. Numpy
  • 5.
    import numpy asnp 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 asnp arr = np.array([[1, 2, 3], [4, 5, 6]]) print(arr) Output- [[1 2 3] [4 5 6]] Example 2-
  • 7.
    Pandas is aPython 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. Data manipulation and analysis Provides DataFrames for structured data operations.s Pandas
  • 8.
    import pandas aspd 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 atext-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() Pyttsx3
  • 10.
    Wikipedia Wikipedia is aPython 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 # findingresult for the search # sentences = 2 refers to numbers of line result = wikipedia.summary("India", sentences = 2) # printing the result print(result)
  • 12.
    A python modulecan 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.
    A Module isa file containing document and statement provide proper organization code reusability namespace management encapsulation 13
  • 14.
    Some Python Modulesare:- datetime 1 webbrowser 2 OS 3 Tkinter 4 random 5
  • 15.
    General-Purpose Libraries os: Forinteracting with the operating system (e.g., file handling, environment variables) sys: Access system-specific parameters and functions re: Regular expressions for pattern matching and text processing datetime: For handling date and time math: Provides mathematical functions like trigonometry, logarithms, etc 15
  • 16.
    datetime The datetime modulesupplies classes for manipulating dates and times. The datetime module has many methods to return information about the date object.
  • 17.
    import datetime x =datetime.datetime.now() print(x.year) print(x.strftime("%A")) Output-2021 Sunday 17 Example- Return the year and name of weekday
  • 18.
    webbrowser The webbrowser moduleincludes 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.
  • 19.
  • 20.
    OS The OS modulein 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.
  • 21.
    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-
  • 22.
    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.
  • 23.
    Tkinter Tkinter is agraphical 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.
  • 24.
    Tkinter Widgets Tkinter providesvarious controls, such as buttons, labels and text boxes used in a GUI application. These controls are commonly called widgets.
  • 25.
    Important method ofTkinter 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. The mainloop() Function:- This method is mainly used to create the main window. Tk(screenName=None, baseName=None, className='Tk', useTk=1) :-
  • 26.
    Random The random moduleis 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.
  • 27.
    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.
  • 28.
    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.
  • 29.
    For more presentation contactus raginijain0208@gmail.com