SlideShare a Scribd company logo
[PYTHON CONCEPTS]
Advanced concepts
OCTOBER 7, 2015
P.D.MANUSHA DILAN
manushadilan@gmail.com
[PYTHON CONCEPTS] | MANUSHA
1 | P a g e
Contents
I. #re Module ……………………………………………………………………………… 2
a. #match
b. #search
c. #findall
d. #sub
II. #lambda functions …………………………………………………………… 5
a. #map
b. #filter
III. #threading .…………………………………………………………………………… 8
[PYTHON CONCEPTS] | MANUSHA
2 | P a g e
#re Module
using for regular expressions
#match
#match with first location of the string
#variable=re.match(pattern,String,optional flags)
import re
mystr="Good programmer should learn Python2,Python3,Perl,Java,Javascript and C"
a=re.match("Good",mystr)
print(a)
<_sre.SRE_Match object; span=(0, 4), match='Good'>
print(type(a))
<class '_sre.SRE_Match'>
print(a.group())
Good
x=re.match("abc",mystr)
print(x)
None
[PYTHON CONCEPTS] | MANUSHA
3 | P a g e
a=re.match("good",mystr,re.I)
print(a)
print(a.group())
<_sre.SRE_Match object; span=(0, 4), match='Good'>
Good
#search
#search the entire string
#variable=re.search(pattern,String,optional flags)
arp="22.22.22.1 0 b4:a9:5a:ff:c8:45 VLAN#222 L"
s=re.search(r"(.+?) +(d) +(.+?)s{2,}(w)*",arp)
print(s.group(1))
22.22.22.1
s1=re.search(r"(.+) +(d) +(.+?)s{2,}(w)*",arp)
print(s1.group(1))
print(s.group(2))
print(s.group(3))
print(s.group(4))
22.22.22.1
0
b4:a9:5a:ff:c8:45 VLAN#222
L
[PYTHON CONCEPTS] | MANUSHA
4 | P a g e
print(s.group())
print(s.group(0))
print(s.groups())
22.22.22.1 0 b4:a9:5a:ff:c8:45 VLAN#222 L
22.22.22.1 0 b4:a9:5a:ff:c8:45 VLAN#222 L
('22.22.22.1', '0', 'b4:a9:5a:ff:c8:45 VLAN#222', 'L')
#findall
f=re.findall(r"dd.d{2}.[0-9][0-9].[0-9]{1,3}",arp)
print(f)
print(type(f))
['22.22.22.1']
<class 'list'>
f=re.findall(r"(dd).(d{2}).([0-9][0-9]).([0-9]{1,3})",arp)
print(f)
[('22', '22', '22', '1')]
arp2="22.22.22.1 0 b4:a9:5a:ff:c8:45 VLAN#222 L 10.10.10.10"
f=re.findall(r"(dd).(d{2}).([0-9][0-9]).([0-9]{1,3})",arp2)
print(f)
[('22', '22', '22', '1'), ('10', '10', '10', '10')]
#sub
b=re.sub(r"d","7",arp2)
print(b)
77.77.77.7 7 b7:a7:7a:ff:c7:77 VLAN#777 L 77.77.77.77
[PYTHON CONCEPTS] | MANUSHA
5 | P a g e
#lambda functions (anonymous functions)
lambda arg1,arg2,....,argN: expression using arguments
a=lambda x,y:x*y
print(a)
print(type(a))
<function <lambda> at 0x03C8C8A0>
<class 'function'>
print(a(2,10))
20
b=lambda list:[x*y for x in range(10) for y in range(5)]+list
print(b([44,66,67]))
[0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 2, 4, 6, 8, 0, 3, 6, 9, 12, 0, 4, 8, 12, 16, 0, 5, 10, 15, 20, 0, 6, 12,
18, 24, 0, 7, 14, 21, 28, 0, 8, 16, 24, 32, 0, 9, 18, 27, 36, 44, 66, 67]
[PYTHON CONCEPTS] | MANUSHA
6 | P a g e
#map
#map(function, sequence)
#return the result of function applied to all items in sequence
def product10(a):
return a*10
list1=range(10)
m=map(product10,list1)
print(m)
<map object at 0x03C64CB0>
for i in m:
print(i)
0 10 20 30 40 50 60 70 80 90
m2=map((lambda a:a*10),list1)
for i in m2:
print(i)
10 20 30 40 50 60 70 80 90
[PYTHON CONCEPTS] | MANUSHA
7 | P a g e
#filter
#filter(function, sequence)
#return all items in sequence for which function is true
f=filter(lambda a:a>5,list1)
for i in f:
print(i)
6 7 8 9
[PYTHON CONCEPTS] | MANUSHA
8 | P a g e
#threading
basic concept of threading
import threading
import time
def myfunc():
print("Start a thread !n")
time.sleep(3)
print("End a thread !!n")
threads=[]
for i in range(5):
th=threading.Thread(target=myfunc)
th.start()
threads.append(th)
for th in threads:
th.join()
Start a thread !
Start a thread !
Start a thread !
Start a thread !
Start a thread !
[PYTHON CONCEPTS] | MANUSHA
9 | P a g e
End a thread !!
End a thread !!
End a thread !!
End a thread !!
End a thread !!
#without threading
import time
def myfunc():
print("Start a thread !n")
time.sleep(3)
print("End a thread !!n")
for i in range(5):
myfunc()
Start a thread !
End a thread !!
Start a thread !
End a thread !!
Start a thread !
End a thread !!
Start a thread !
End a thread !!
Start a thread !
End a thread !!

More Related Content

What's hot

Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
jehan1987
 
support vector regression
support vector regressionsupport vector regression
support vector regression
Akhilesh Joshi
 
Numpy
NumpyNumpy
NUMPY
NUMPY NUMPY
Resolution,forward backward chaining
Resolution,forward backward chainingResolution,forward backward chaining
Resolution,forward backward chaining
Ann Rose
 
Introduction to NumPy
Introduction to NumPyIntroduction to NumPy
Introduction to NumPy
Huy Nguyen
 
Data visualization in Python
Data visualization in PythonData visualization in Python
Data visualization in Python
Marc Garcia
 
Gradient descent optimizer
Gradient descent optimizerGradient descent optimizer
Gradient descent optimizer
Hojin Yang
 
NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
EN1036VivekSingh
 
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data Structure
Keno benti
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
Soba Arjun
 
Introduction to numpy
Introduction to numpyIntroduction to numpy
Introduction to numpy
Gaurav Aggarwal
 
Python matplotlib cheat_sheet
Python matplotlib cheat_sheetPython matplotlib cheat_sheet
Python matplotlib cheat_sheet
Nishant Upadhyay
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
Girish Khanzode
 
Avl trees
Avl treesAvl trees
Avl treesppreeta
 
Data Analysis with Python Pandas
Data Analysis with Python PandasData Analysis with Python Pandas
Data Analysis with Python Pandas
Neeru Mittal
 
Big o notation
Big o notationBig o notation
Big o notation
hamza mushtaq
 
Python Seaborn Data Visualization
Python Seaborn Data Visualization Python Seaborn Data Visualization
Python Seaborn Data Visualization
Sourabh Sahu
 
CMSC 56 | Lecture 8: Growth of Functions
CMSC 56 | Lecture 8: Growth of FunctionsCMSC 56 | Lecture 8: Growth of Functions
CMSC 56 | Lecture 8: Growth of Functions
allyn joy calcaben
 
Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)
Gaurav Mittal
 

What's hot (20)

Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
support vector regression
support vector regressionsupport vector regression
support vector regression
 
Numpy
NumpyNumpy
Numpy
 
NUMPY
NUMPY NUMPY
NUMPY
 
Resolution,forward backward chaining
Resolution,forward backward chainingResolution,forward backward chaining
Resolution,forward backward chaining
 
Introduction to NumPy
Introduction to NumPyIntroduction to NumPy
Introduction to NumPy
 
Data visualization in Python
Data visualization in PythonData visualization in Python
Data visualization in Python
 
Gradient descent optimizer
Gradient descent optimizerGradient descent optimizer
Gradient descent optimizer
 
NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
 
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data Structure
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
 
Introduction to numpy
Introduction to numpyIntroduction to numpy
Introduction to numpy
 
Python matplotlib cheat_sheet
Python matplotlib cheat_sheetPython matplotlib cheat_sheet
Python matplotlib cheat_sheet
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
 
Avl trees
Avl treesAvl trees
Avl trees
 
Data Analysis with Python Pandas
Data Analysis with Python PandasData Analysis with Python Pandas
Data Analysis with Python Pandas
 
Big o notation
Big o notationBig o notation
Big o notation
 
Python Seaborn Data Visualization
Python Seaborn Data Visualization Python Seaborn Data Visualization
Python Seaborn Data Visualization
 
CMSC 56 | Lecture 8: Growth of Functions
CMSC 56 | Lecture 8: Growth of FunctionsCMSC 56 | Lecture 8: Growth of Functions
CMSC 56 | Lecture 8: Growth of Functions
 
Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)
 

Similar to Advanced python concepts

Computer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdfComputer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdf
PranavAnil9
 
A practical work of matlab
A practical work of matlabA practical work of matlab
A practical work of matlab
SalanSD
 
Python Manuel-R2021.pdf
Python Manuel-R2021.pdfPython Manuel-R2021.pdf
Python Manuel-R2021.pdf
RamprakashSingaravel1
 
Introduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfIntroduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdf
TulasiramKandula1
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
vrickens
 
Study material ip class 12th
Study material ip class 12thStudy material ip class 12th
Study material ip class 12th
animesh dwivedi
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
Abdul Haseeb
 
Introduction to Data Science With R Lab Record
Introduction to Data Science With R Lab RecordIntroduction to Data Science With R Lab Record
Introduction to Data Science With R Lab Record
Lakshmi Sarvani Videla
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
062MayankSinghal
 
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
The Statistical and Applied Mathematical Sciences Institute
 
Big datacourse
Big datacourseBig datacourse
Big datacourse
Massimiliano Ruocco
 
Design of Sugarcane Roots Remover
Design of Sugarcane Roots RemoverDesign of Sugarcane Roots Remover
Design of Sugarcane Roots Remover
IRJET Journal
 
Python High Level Functions_Ch 11.ppt
Python High Level Functions_Ch 11.pptPython High Level Functions_Ch 11.ppt
Python High Level Functions_Ch 11.ppt
AnishaJ7
 
Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPy
Kimikazu Kato
 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
simenehanmut
 
R programming lab 1 - jupyter notebook
R programming lab   1 - jupyter notebookR programming lab   1 - jupyter notebook
R programming lab 1 - jupyter notebook
Ashwini Mathur
 
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
Task4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docxTask4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docx
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
josies1
 
The Elaboration of Algorithm for Selectionand Functions Distribution of Multi...
The Elaboration of Algorithm for Selectionand Functions Distribution of Multi...The Elaboration of Algorithm for Selectionand Functions Distribution of Multi...
The Elaboration of Algorithm for Selectionand Functions Distribution of Multi...
ijtsrd
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
ARVIND PANDE
 

Similar to Advanced python concepts (20)

Computer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdfComputer Science CS Project Matrix CBSE Class 12th XII .pdf
Computer Science CS Project Matrix CBSE Class 12th XII .pdf
 
A practical work of matlab
A practical work of matlabA practical work of matlab
A practical work of matlab
 
Python Manuel-R2021.pdf
Python Manuel-R2021.pdfPython Manuel-R2021.pdf
Python Manuel-R2021.pdf
 
Introduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfIntroduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdf
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
 
Study material ip class 12th
Study material ip class 12thStudy material ip class 12th
Study material ip class 12th
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
 
Introduction to Data Science With R Lab Record
Introduction to Data Science With R Lab RecordIntroduction to Data Science With R Lab Record
Introduction to Data Science With R Lab Record
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
 
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
 
Big datacourse
Big datacourseBig datacourse
Big datacourse
 
Design of Sugarcane Roots Remover
Design of Sugarcane Roots RemoverDesign of Sugarcane Roots Remover
Design of Sugarcane Roots Remover
 
Python High Level Functions_Ch 11.ppt
Python High Level Functions_Ch 11.pptPython High Level Functions_Ch 11.ppt
Python High Level Functions_Ch 11.ppt
 
Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPy
 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
 
R programming lab 1 - jupyter notebook
R programming lab   1 - jupyter notebookR programming lab   1 - jupyter notebook
R programming lab 1 - jupyter notebook
 
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
Task4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docxTask4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docx
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
 
The Elaboration of Algorithm for Selectionand Functions Distribution of Multi...
The Elaboration of Algorithm for Selectionand Functions Distribution of Multi...The Elaboration of Algorithm for Selectionand Functions Distribution of Multi...
The Elaboration of Algorithm for Selectionand Functions Distribution of Multi...
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
 

More from Manusha Dilan

Cell aging
Cell agingCell aging
Cell aging
Manusha Dilan
 
Waterfall model
Waterfall modelWaterfall model
Waterfall model
Manusha Dilan
 
Telco app development
Telco app developmentTelco app development
Telco app development
Manusha Dilan
 
Jade Application Wedding Planner (Groom Assist)
Jade Application Wedding Planner (Groom Assist)Jade Application Wedding Planner (Groom Assist)
Jade Application Wedding Planner (Groom Assist)
Manusha Dilan
 
E commerce application using asp.net mvc4
E commerce application using asp.net mvc4E commerce application using asp.net mvc4
E commerce application using asp.net mvc4
Manusha Dilan
 
Ruhune maha wiharaya(රුහුණේ මහා විහාරය )
Ruhune maha wiharaya(රුහුණේ මහා විහාරය )Ruhune maha wiharaya(රුහුණේ මහා විහාරය )
Ruhune maha wiharaya(රුහුණේ මහා විහාරය )
Manusha Dilan
 
B2C Models
B2C ModelsB2C Models
B2C Models
Manusha Dilan
 
Python collections
Python collectionsPython collections
Python collections
Manusha Dilan
 
Selective repeat protocol
Selective repeat protocolSelective repeat protocol
Selective repeat protocol
Manusha Dilan
 
Cellular concepts
Cellular conceptsCellular concepts
Cellular concepts
Manusha Dilan
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
Manusha Dilan
 
HCI_chapter_09-Evaluation_techniques
HCI_chapter_09-Evaluation_techniquesHCI_chapter_09-Evaluation_techniques
HCI_chapter_09-Evaluation_techniques
Manusha Dilan
 

More from Manusha Dilan (13)

Cell aging
Cell agingCell aging
Cell aging
 
Waterfall model
Waterfall modelWaterfall model
Waterfall model
 
Telco app development
Telco app developmentTelco app development
Telco app development
 
Jade Application Wedding Planner (Groom Assist)
Jade Application Wedding Planner (Groom Assist)Jade Application Wedding Planner (Groom Assist)
Jade Application Wedding Planner (Groom Assist)
 
E commerce application using asp.net mvc4
E commerce application using asp.net mvc4E commerce application using asp.net mvc4
E commerce application using asp.net mvc4
 
Ruhune maha wiharaya(රුහුණේ මහා විහාරය )
Ruhune maha wiharaya(රුහුණේ මහා විහාරය )Ruhune maha wiharaya(රුහුණේ මහා විහාරය )
Ruhune maha wiharaya(රුහුණේ මහා විහාරය )
 
B2C Models
B2C ModelsB2C Models
B2C Models
 
Python collections
Python collectionsPython collections
Python collections
 
Selective repeat protocol
Selective repeat protocolSelective repeat protocol
Selective repeat protocol
 
Cellular concepts
Cellular conceptsCellular concepts
Cellular concepts
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
 
HCI_chapter_09-Evaluation_techniques
HCI_chapter_09-Evaluation_techniquesHCI_chapter_09-Evaluation_techniques
HCI_chapter_09-Evaluation_techniques
 
Lan technologies
Lan technologiesLan technologies
Lan technologies
 

Recently uploaded

The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 

Recently uploaded (20)

The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 

Advanced python concepts

  • 1. [PYTHON CONCEPTS] Advanced concepts OCTOBER 7, 2015 P.D.MANUSHA DILAN manushadilan@gmail.com
  • 2. [PYTHON CONCEPTS] | MANUSHA 1 | P a g e Contents I. #re Module ……………………………………………………………………………… 2 a. #match b. #search c. #findall d. #sub II. #lambda functions …………………………………………………………… 5 a. #map b. #filter III. #threading .…………………………………………………………………………… 8
  • 3. [PYTHON CONCEPTS] | MANUSHA 2 | P a g e #re Module using for regular expressions #match #match with first location of the string #variable=re.match(pattern,String,optional flags) import re mystr="Good programmer should learn Python2,Python3,Perl,Java,Javascript and C" a=re.match("Good",mystr) print(a) <_sre.SRE_Match object; span=(0, 4), match='Good'> print(type(a)) <class '_sre.SRE_Match'> print(a.group()) Good x=re.match("abc",mystr) print(x) None
  • 4. [PYTHON CONCEPTS] | MANUSHA 3 | P a g e a=re.match("good",mystr,re.I) print(a) print(a.group()) <_sre.SRE_Match object; span=(0, 4), match='Good'> Good #search #search the entire string #variable=re.search(pattern,String,optional flags) arp="22.22.22.1 0 b4:a9:5a:ff:c8:45 VLAN#222 L" s=re.search(r"(.+?) +(d) +(.+?)s{2,}(w)*",arp) print(s.group(1)) 22.22.22.1 s1=re.search(r"(.+) +(d) +(.+?)s{2,}(w)*",arp) print(s1.group(1)) print(s.group(2)) print(s.group(3)) print(s.group(4)) 22.22.22.1 0 b4:a9:5a:ff:c8:45 VLAN#222 L
  • 5. [PYTHON CONCEPTS] | MANUSHA 4 | P a g e print(s.group()) print(s.group(0)) print(s.groups()) 22.22.22.1 0 b4:a9:5a:ff:c8:45 VLAN#222 L 22.22.22.1 0 b4:a9:5a:ff:c8:45 VLAN#222 L ('22.22.22.1', '0', 'b4:a9:5a:ff:c8:45 VLAN#222', 'L') #findall f=re.findall(r"dd.d{2}.[0-9][0-9].[0-9]{1,3}",arp) print(f) print(type(f)) ['22.22.22.1'] <class 'list'> f=re.findall(r"(dd).(d{2}).([0-9][0-9]).([0-9]{1,3})",arp) print(f) [('22', '22', '22', '1')] arp2="22.22.22.1 0 b4:a9:5a:ff:c8:45 VLAN#222 L 10.10.10.10" f=re.findall(r"(dd).(d{2}).([0-9][0-9]).([0-9]{1,3})",arp2) print(f) [('22', '22', '22', '1'), ('10', '10', '10', '10')] #sub b=re.sub(r"d","7",arp2) print(b) 77.77.77.7 7 b7:a7:7a:ff:c7:77 VLAN#777 L 77.77.77.77
  • 6. [PYTHON CONCEPTS] | MANUSHA 5 | P a g e #lambda functions (anonymous functions) lambda arg1,arg2,....,argN: expression using arguments a=lambda x,y:x*y print(a) print(type(a)) <function <lambda> at 0x03C8C8A0> <class 'function'> print(a(2,10)) 20 b=lambda list:[x*y for x in range(10) for y in range(5)]+list print(b([44,66,67])) [0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 2, 4, 6, 8, 0, 3, 6, 9, 12, 0, 4, 8, 12, 16, 0, 5, 10, 15, 20, 0, 6, 12, 18, 24, 0, 7, 14, 21, 28, 0, 8, 16, 24, 32, 0, 9, 18, 27, 36, 44, 66, 67]
  • 7. [PYTHON CONCEPTS] | MANUSHA 6 | P a g e #map #map(function, sequence) #return the result of function applied to all items in sequence def product10(a): return a*10 list1=range(10) m=map(product10,list1) print(m) <map object at 0x03C64CB0> for i in m: print(i) 0 10 20 30 40 50 60 70 80 90 m2=map((lambda a:a*10),list1) for i in m2: print(i) 10 20 30 40 50 60 70 80 90
  • 8. [PYTHON CONCEPTS] | MANUSHA 7 | P a g e #filter #filter(function, sequence) #return all items in sequence for which function is true f=filter(lambda a:a>5,list1) for i in f: print(i) 6 7 8 9
  • 9. [PYTHON CONCEPTS] | MANUSHA 8 | P a g e #threading basic concept of threading import threading import time def myfunc(): print("Start a thread !n") time.sleep(3) print("End a thread !!n") threads=[] for i in range(5): th=threading.Thread(target=myfunc) th.start() threads.append(th) for th in threads: th.join() Start a thread ! Start a thread ! Start a thread ! Start a thread ! Start a thread !
  • 10. [PYTHON CONCEPTS] | MANUSHA 9 | P a g e End a thread !! End a thread !! End a thread !! End a thread !! End a thread !! #without threading import time def myfunc(): print("Start a thread !n") time.sleep(3) print("End a thread !!n") for i in range(5): myfunc() Start a thread ! End a thread !! Start a thread ! End a thread !! Start a thread ! End a thread !! Start a thread ! End a thread !! Start a thread ! End a thread !!