SlideShare a Scribd company logo
1 of 15
Brief Tour of the Standard Library
Matching patterns
Definition Program
 Regular expressions are
complicated mini-language. They
rely on special characters to
match unknown strings, but let's
start with literal characters, such
as letters, numbers, and the space
character, which always match
themselves.
 The “re” module which comes
with every python installation
provides regular expression
support.
import re
search_string = "Techno Plus Logic"
pattern = "Tec"
match = re.match(pattern,
search_string)
if match:
print("Pattern Found ",
match.group())
else:
Math functions
Definition Program
 Python has a math module that
provides most of the familiar
mathematical functions. A
module is a file that contains a
collection of related functions.
 Before we can use the module,
we have to import it:
 >>> import math
 print(math.sin(45))
 print(math.tan(45))
 print(math.cos(45))
 print(math.log10(45))
 print(math.sqrt(4))
 print(math.ceil(4.55565))
 print(math.degrees(45))
 print(math.pow(4,5))
Internet Access
Definition
Checking Internet Connection in
Python
 Nowadays, the Internet is an
essential part of our day-to-day
lives. If the server is down even for
a minute, then we check the Internet
connectivity in various ways. Can
Python help us check the
connectivity? Yes, we can use
Python language for checking the
internet connection. In this tutorial,
we will find out whether the
computer is connected to the internet
or not.
1. using urllib package.
2. using an IP address/socket
package.
Date & Time:
Definition
The types of objects in datetime are
as below.
 In python, datetime is a module
which provides different classes
to work with dates and times.
 date
 time
 datetime
 timedelta
 tzinfo
 timezone
Date Object: Pragram
 Date object depicts the date as
date(year, month, day) in an ideal
Gregorian calendar. Syntax of the
Date class is represented as
below.
 Syntax:
 class
datetime.date(year,month,day)
>>> from datetime import date
# method today() shows the today's date
>>> today=date.today()
>>> today
datetime.date(2017, 11, 7)
>>> x=d.timetuple()
>>> today=x
>>> x
time.struct_time(tm_year=2017, tm_mon=8,
tm_mday=15, tm_hour=0, tm_min=0, tm_sec=0,
tm_wday=1, tm_yday=227, tm_isdst=-1)
# assigning the date
>>> d=date(2017,11,7)
Multithreading
Concept Definition
 In computing, a process is an
instance of a computer program that
is being executed. Any process has 3
basic components:
 An executable program.
 The associated data needed by the
program (variables, work space,
buffers, etc.).
 The execution context of the
program (State of process).
 A thread is an entity within a process
that can be scheduled for execution.
Also, it is the smallest unit of
processing that can be performed in an
OS (Operating System).
 In simple words, a thread is a sequence
of such instructions within a program
that can be executed independently of
other code. For simplicity, you can
assume that a thread is simply a subset
of a process!
A thread contains all this information in a Thread
Control Block (TCB):
 Thread Identifier: Unique id (TID) is assigned to every new thread
Stack pointer: Points to thread’s stack in the process. Stack contains the
local variables under thread’s scope.
Program counter: a register which stores the address of the instruction
currently being executed by thread.
Thread state: can be running, ready, waiting, start or done.
Thread’s register set: registers assigned to thread for computations.
Parent process Pointer: A pointer to the Process control block (PCB) of
the process that the thread lives on.
Data compression
Definition Program
 Data compression is the process of
modifying, encoding or converting
the bits structure of data in such a
way that it consumes less space on
disk. It enables reducing the storage
size of one or more data instances or
elements. Data compression is also
known as source coding or bit-rate
reduction.
 Zip is the build-in.
 >>> import zlib
 >>> s = b'you learn learnt learning
the data daily '
 >>>len(s)
 41
 >>>
 >>> t = zlib.compress(s)
 >>>len(t)
 39
GUI Interface
Definition
 Tkinter is the standard GUI
library for Python. Python when
combined with Tkinter provides a
fast and easy way to create GUI
applications. Tkinter provides a
powerful object-oriented interface
to the Tk GUI toolkit.
 Import Tkinter in program.
Sr.No. Operator
1
Button
2
Canvas
3
Checkbutton
4
Entry
5
Frame
6
Label
7
Listbox
8
Menubutton
9
Menu
10
Message
Turtle Programming
Definition
 “Turtle” is a Python feature like a
drawing board, which lets us
command a turtle to draw all over
it! We can use functions like
turtle.forward(…) and
turtle.right(…) which can move
the turtle around. Commonly
used turtle methods are.
 Import turtle in program.
METHOD
Turtle()
forward()
backward()
right()
left()
penup()
pendown()
up()
down()
color()
Program
Testing
Definition
Unit Test
 Testing determines whether
software runs correctly based on
specific inputs and identifies
defects that need to be fixed.
 Unit Testing in Python is done to
identify bugs early in the
development stage of the
application when bugs are less
recurrent and less expensive to
fix. A unit test is a scripted code
level test designed in Python to
verify a small "unit" of
functionality.
Why is testing important?
 As software scales in codebase size, it's impossible for a person or even a large team to
keep up with all of the changes and the interactions between the changes. Automated
testing is the only proven method for building reliable software once they grow past the
point of a simple prototype. Many major software program development failures can be
traced back to inadequate or a complete lack of testing.
 It's impossible to know whether software works properly unless it is tested. While
testing can be done manually, by a user clicking buttons or typing in input, it should be
performed automatically by writing software programs that test the application under
test.
 There are many forms of testing and they should all be used together. When a single
function of a program is isolated for testing, that is called unit testing. Testing more than
a single function in an application at the same time is known as integration testing. User
interface testing ensures the correctness of how a user would interact with the software.
There are even more forms of testing that large programs need, such as load
testing, database testing, and browser testing (for web applications).
Writing and Running Test case
 Create a file named tests.py in the folder named “tests”.
 In tests.py import unittest.
 Create a class named TestClass which inherits from the class unittest.
TestCase.
 Create a test method
 To run the tests, we just defined, we need to call the method unittest.

More Related Content

What's hot

What's hot (20)

Clone detection in Python
Clone detection in PythonClone detection in Python
Clone detection in Python
 
C# program structure
C# program structureC# program structure
C# program structure
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 
Python Workshop Part 2. LUG Maniapl
Python Workshop Part 2. LUG ManiaplPython Workshop Part 2. LUG Maniapl
Python Workshop Part 2. LUG Maniapl
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
 
What are Data structures in Python? | List, Dictionary, Tuple Explained | Edu...
What are Data structures in Python? | List, Dictionary, Tuple Explained | Edu...What are Data structures in Python? | List, Dictionary, Tuple Explained | Edu...
What are Data structures in Python? | List, Dictionary, Tuple Explained | Edu...
 
Python Programming Essentials - M12 - Lists
Python Programming Essentials - M12 - ListsPython Programming Essentials - M12 - Lists
Python Programming Essentials - M12 - Lists
 
Python strings presentation
Python strings presentationPython strings presentation
Python strings presentation
 
Functions and modules in python
Functions and modules in pythonFunctions and modules in python
Functions and modules in python
 
Python programming : Control statements
Python programming : Control statementsPython programming : Control statements
Python programming : Control statements
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
Python functions
Python functionsPython functions
Python functions
 
Python Collections Tutorial | Edureka
Python Collections Tutorial | EdurekaPython Collections Tutorial | Edureka
Python Collections Tutorial | Edureka
 
Python
PythonPython
Python
 
Lesson 02 python keywords and identifiers
Lesson 02   python keywords and identifiersLesson 02   python keywords and identifiers
Lesson 02 python keywords and identifiers
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
Lists
ListsLists
Lists
 
Data types in python lecture (2)
Data types in python lecture (2)Data types in python lecture (2)
Data types in python lecture (2)
 

Similar to Standard Libraries in Python Programming

Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
Aarti P
 

Similar to Standard Libraries in Python Programming (20)

pythonlibrariesandmodules-210530042906.docx
pythonlibrariesandmodules-210530042906.docxpythonlibrariesandmodules-210530042906.docx
pythonlibrariesandmodules-210530042906.docx
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and Modules
 
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
 
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
 
Python for Machine Learning
Python for Machine LearningPython for Machine Learning
Python for Machine Learning
 
Python Programming | JNTUK | UNIT 1 | Lecture 3
Python Programming | JNTUK | UNIT 1 | Lecture 3Python Programming | JNTUK | UNIT 1 | Lecture 3
Python Programming | JNTUK | UNIT 1 | Lecture 3
 
Lec1
Lec1Lec1
Lec1
 
Lec1
Lec1Lec1
Lec1
 
Python Training on python and SQL PPT.pptx
Python Training on python and SQL PPT.pptxPython Training on python and SQL PPT.pptx
Python Training on python and SQL PPT.pptx
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 
Lect1.pptx
Lect1.pptxLect1.pptx
Lect1.pptx
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptx
 
HOW TO DOWNLOAD MICROSOFT WORD IN ANDROID, and How to convert doc file into ...
HOW TO DOWNLOAD MICROSOFT WORD  IN ANDROID, and How to convert doc file into ...HOW TO DOWNLOAD MICROSOFT WORD  IN ANDROID, and How to convert doc file into ...
HOW TO DOWNLOAD MICROSOFT WORD IN ANDROID, and How to convert doc file into ...
 
The Evolution Of Eclipse 1. 1 )
The Evolution Of Eclipse 1. 1 )The Evolution Of Eclipse 1. 1 )
The Evolution Of Eclipse 1. 1 )
 
ArduinoWorkshop2.pdf
ArduinoWorkshop2.pdfArduinoWorkshop2.pdf
ArduinoWorkshop2.pdf
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
Lec1
Lec1Lec1
Lec1
 
Chapter 5 - THREADING & REGULAR exp - MAULIK BORSANIYA
Chapter 5 - THREADING & REGULAR exp - MAULIK BORSANIYAChapter 5 - THREADING & REGULAR exp - MAULIK BORSANIYA
Chapter 5 - THREADING & REGULAR exp - MAULIK BORSANIYA
 

Recently uploaded

"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 

Recently uploaded (20)

UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptx
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .ppt
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...
 
Post office management system project ..pdf
Post office management system project ..pdfPost office management system project ..pdf
Post office management system project ..pdf
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
 
8086 Microprocessor Architecture: 16-bit microprocessor
8086 Microprocessor Architecture: 16-bit microprocessor8086 Microprocessor Architecture: 16-bit microprocessor
8086 Microprocessor Architecture: 16-bit microprocessor
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 

Standard Libraries in Python Programming

  • 1. Brief Tour of the Standard Library
  • 2. Matching patterns Definition Program  Regular expressions are complicated mini-language. They rely on special characters to match unknown strings, but let's start with literal characters, such as letters, numbers, and the space character, which always match themselves.  The “re” module which comes with every python installation provides regular expression support. import re search_string = "Techno Plus Logic" pattern = "Tec" match = re.match(pattern, search_string) if match: print("Pattern Found ", match.group()) else:
  • 3. Math functions Definition Program  Python has a math module that provides most of the familiar mathematical functions. A module is a file that contains a collection of related functions.  Before we can use the module, we have to import it:  >>> import math  print(math.sin(45))  print(math.tan(45))  print(math.cos(45))  print(math.log10(45))  print(math.sqrt(4))  print(math.ceil(4.55565))  print(math.degrees(45))  print(math.pow(4,5))
  • 4. Internet Access Definition Checking Internet Connection in Python  Nowadays, the Internet is an essential part of our day-to-day lives. If the server is down even for a minute, then we check the Internet connectivity in various ways. Can Python help us check the connectivity? Yes, we can use Python language for checking the internet connection. In this tutorial, we will find out whether the computer is connected to the internet or not. 1. using urllib package. 2. using an IP address/socket package.
  • 5. Date & Time: Definition The types of objects in datetime are as below.  In python, datetime is a module which provides different classes to work with dates and times.  date  time  datetime  timedelta  tzinfo  timezone
  • 6. Date Object: Pragram  Date object depicts the date as date(year, month, day) in an ideal Gregorian calendar. Syntax of the Date class is represented as below.  Syntax:  class datetime.date(year,month,day) >>> from datetime import date # method today() shows the today's date >>> today=date.today() >>> today datetime.date(2017, 11, 7) >>> x=d.timetuple() >>> today=x >>> x time.struct_time(tm_year=2017, tm_mon=8, tm_mday=15, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=1, tm_yday=227, tm_isdst=-1) # assigning the date >>> d=date(2017,11,7)
  • 7. Multithreading Concept Definition  In computing, a process is an instance of a computer program that is being executed. Any process has 3 basic components:  An executable program.  The associated data needed by the program (variables, work space, buffers, etc.).  The execution context of the program (State of process).  A thread is an entity within a process that can be scheduled for execution. Also, it is the smallest unit of processing that can be performed in an OS (Operating System).  In simple words, a thread is a sequence of such instructions within a program that can be executed independently of other code. For simplicity, you can assume that a thread is simply a subset of a process!
  • 8. A thread contains all this information in a Thread Control Block (TCB):  Thread Identifier: Unique id (TID) is assigned to every new thread Stack pointer: Points to thread’s stack in the process. Stack contains the local variables under thread’s scope. Program counter: a register which stores the address of the instruction currently being executed by thread. Thread state: can be running, ready, waiting, start or done. Thread’s register set: registers assigned to thread for computations. Parent process Pointer: A pointer to the Process control block (PCB) of the process that the thread lives on.
  • 9. Data compression Definition Program  Data compression is the process of modifying, encoding or converting the bits structure of data in such a way that it consumes less space on disk. It enables reducing the storage size of one or more data instances or elements. Data compression is also known as source coding or bit-rate reduction.  Zip is the build-in.  >>> import zlib  >>> s = b'you learn learnt learning the data daily '  >>>len(s)  41  >>>  >>> t = zlib.compress(s)  >>>len(t)  39
  • 10. GUI Interface Definition  Tkinter is the standard GUI library for Python. Python when combined with Tkinter provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit.  Import Tkinter in program. Sr.No. Operator 1 Button 2 Canvas 3 Checkbutton 4 Entry 5 Frame 6 Label 7 Listbox 8 Menubutton 9 Menu 10 Message
  • 11. Turtle Programming Definition  “Turtle” is a Python feature like a drawing board, which lets us command a turtle to draw all over it! We can use functions like turtle.forward(…) and turtle.right(…) which can move the turtle around. Commonly used turtle methods are.  Import turtle in program. METHOD Turtle() forward() backward() right() left() penup() pendown() up() down() color()
  • 13. Testing Definition Unit Test  Testing determines whether software runs correctly based on specific inputs and identifies defects that need to be fixed.  Unit Testing in Python is done to identify bugs early in the development stage of the application when bugs are less recurrent and less expensive to fix. A unit test is a scripted code level test designed in Python to verify a small "unit" of functionality.
  • 14. Why is testing important?  As software scales in codebase size, it's impossible for a person or even a large team to keep up with all of the changes and the interactions between the changes. Automated testing is the only proven method for building reliable software once they grow past the point of a simple prototype. Many major software program development failures can be traced back to inadequate or a complete lack of testing.  It's impossible to know whether software works properly unless it is tested. While testing can be done manually, by a user clicking buttons or typing in input, it should be performed automatically by writing software programs that test the application under test.  There are many forms of testing and they should all be used together. When a single function of a program is isolated for testing, that is called unit testing. Testing more than a single function in an application at the same time is known as integration testing. User interface testing ensures the correctness of how a user would interact with the software. There are even more forms of testing that large programs need, such as load testing, database testing, and browser testing (for web applications).
  • 15. Writing and Running Test case  Create a file named tests.py in the folder named “tests”.  In tests.py import unittest.  Create a class named TestClass which inherits from the class unittest. TestCase.  Create a test method  To run the tests, we just defined, we need to call the method unittest.