SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
Python:
Data structures, control foo,
OO Programming, Regular
Expressions, System Programming
AAA-Python Edition
Plan
●
1- if / else , For, While
●
2- Lists, Tuples, List comprehensions
●
3- Dictionaries
●
4- Sets
●
5- Object Oriented Programming
●
6- Regular Expression
●
7- System Programming
3
1-1-if/else,For,While
[By Amina Delali]
If / else
●
These statements are used to control ohich block of code to
execute:
If the “condition” is true
(the corresponding expression
Is Evaluated to True), then
the if “clause” is executed
(the if block)
The condition was false, so
The “else” clause was executed
The “elif” clause is executed,
If its condition is true
4
1-1-if/else,For,While
[By Amina Delali]
While
●
This statement is used to control hoo many times a block of
code has to be executed:
While the condition is true, the block code
will be executed.
In this loop, the block has been executed 2 times
5
1-1-if/else,For,While
[By Amina Delali]
For
●
This statement is used to execute a block of code a certain
number of times
“i” will take its values from the numbers
created by the ‘range’ function
This “range” function: will generate
a range of numbers from “0” to “4-1”
This loop will be executed 4 times
6
2-Lists,Tuples,
Listcomprehensions
[By Amina Delali]
List
●
A list is a value that contains multiple values.
l1 and l2 are lists
Tuple
A a tuple is a list of immutable values.
t1 and t2 are tuples
Function “list” to create a list
7
2-Lists,Tuples,
Listcomprehensions
[By Amina Delali]
Lists and tuples (suite)
Access to the first element
Modifying the value of the
element of index 0 (first element)
Trying to modify the value of an element of a tuple
8
2-Lists,Tuples,
Listcomprehensions
[By Amina Delali]
Some operations with lists
Concatenating two
lists
a slice: values
From index 2 to index 4
Number of elements
of a list
9
2-Lists,Tuples,
Listcomprehensions
[By Amina Delali]
Some operations with lists (suite)
“not” with “in”
Iterate through list
Functions “min” and “max”
Affecting list values
To multiple variables
10
2-Lists,Tuples,
Listcomprehensions
[By Amina Delali]
List comprehensions
Filtering elements
Creating new elements from range
List of lists using 3 loops
11
2-Lists,Tuples,
Listcomprehensions
[By Amina Delali]
List methods Finding an element in a list
●
A list has some methods. We will talk about methods later.
Add an element to the
end of a list
Insert an element at a certain position
Remove an element
from a list
12
3-Dictionaries
[By Amina Delali]
●
Dictionaries
●
A dictionary is a list of values with corresponding keys
key
Value
Method that returns
the dictionary values
Value
Method that returns
the dictionary keys
13
3-Dictionaries
[By Amina Delali]
●
Dictionaries (suite)
Method that returns the
dictionary items: pairs of key,value
The key doesn’t exist
so a default value is given
The key exists, its value
Is returned
A key is created with a
default value
The key already exists,
So no other key is created
14
4-Sets
[By Amina Delali]
Sets
●
A set is a list of distinct values
The duplicates
are eliminated
Is s1 a subset of
s2
Elements in
S1 and not in
s2
Intersection between
s1 and s2
15
5-ObjectOriented
Programming
[By Amina Delali]
Classes
●
In Python, we can defne “classes”: a defned prototype that
encapsulates data and the functions to operate on them.
●
An instance of a class is called an “object”. We already used
objects when we used lists, sets and dictionaries.
Name of the class
Data
attribute
A method (a function
attribute)
To indicate that elements of
range are not the elements
of the list
Called when creating
an object of that class
16
5-ObjectOriented
Programming
[By Amina Delali]
Classes
A comment
Optional attribute for
function print
Each time we use
myList, we ensure
that length==
len(myList)
17
5-ObjectOriented
Programming
[By Amina Delali]
Classes
A subclass of class MyTable
Inherits all its methods
and data attributes:
We can use them without
redefining them.
Redefine “myType”
(already defined in MyTable)
It’s overriding myType
parent class methodObject creation(
Call of __init__)
Call of a method
Access of a data attribute
18
5-ObjectOriented
Programming
[By Amina Delali]
Classes
Same class,
different
values
c an instance
of MyTable2:
Use of __init__
method of class
MyTable
An other different subclass
List of 4 instances of different
classes
Call of the same
Method had
different results
==
Polymorphism
19
6-Regularexpressions
[By Amina Delali]
Regular expressions
●
A regular expression is a description of pattern of text
A year from 1970 to 2999
A month: composed of:
0 and a digit from 1 to 9 (0[1-9])
Or (|)
1 and a digit from 0 to 2 (1[0-2])
Search a pattern at the start
One or
more a(+)
Search for the first
date
3 digits
Need of module re
20
7-System
programming
[By Amina Delali]
System Programming
●
We will focus on system programming in Colab.
●
Some Python functions can be simply done on Colab.
●
For example the bash commands: they can be used as they are
by prefxing them by “!” or “%”: !ls, !mkdir, !git, !pip, %cd … etc
Running ‘ls’
using subprocess
Import a local
file
After selecting the
Script file, import it
21
7-System
programming
[By Amina Delali]
System Programming
●
Second way of using a user defned script:
●
We have to mount Google Drive
Using a defined function
Running the file as a script
To avoid using the full path of the
script, use sys.path.append
22
7-System
programming
[By Amina Delali]
System Programming Using ‘!cat’ to print the content
of the file
Creating the file path
Open and read the file content into a list
Print the list
Use if__name__ ==”__main__” for the code
To be executed if the module is not imported
And run as a script
References
●
Duchesnay Edouard and Löfstedt Tommy. Statistics and machine learning in
python release 0.2. On-line at
ftp://ftp.cea.fr/pub/unati/people/educhesnay/pystatml/M1_IMSV/StatisticsMachineL
earningPythonDraft.pdf.
Accessed on 23-09-2018.
●
Python Software Foundation. The python standard library. On-line at
https://docs.python.org/3.6/library/index.html. Accessed on 23-09-2018.
●
Joel Grus. Data science from scratch: frst principles with python. O’Reilly Media,
Inc, 2015.
●
Chandat Sunny. Learn Python in 24 Hours. CreateSpace Independent Publishing
Platform, 2016.
●
Al Sweigart. Automate the boring stuf with Python: practical programming for
total beginners. No Starch Press, 2015.
Thank
you!
FOR ALL YOUR TIME

Contenu connexe

Tendances

Tendances (20)

Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
 
Data types in python
Data types in pythonData types in python
Data types in python
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming Languge
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
11 Unit 1 Chapter 02 Python Fundamentals
11  Unit 1 Chapter 02 Python Fundamentals11  Unit 1 Chapter 02 Python Fundamentals
11 Unit 1 Chapter 02 Python Fundamentals
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Let’s Learn Python An introduction to Python
Let’s Learn Python An introduction to Python Let’s Learn Python An introduction to Python
Let’s Learn Python An introduction to Python
 
Python45 2
Python45 2Python45 2
Python45 2
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
 
PHP
 PHP PHP
PHP
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data type
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with Python
 
Numeric Data types in Python
Numeric Data types in PythonNumeric Data types in Python
Numeric Data types in Python
 
Python with data Sciences
Python with data SciencesPython with data Sciences
Python with data Sciences
 
Python
PythonPython
Python
 
Python training
Python trainingPython training
Python training
 

Similaire à Aaa ped-3. Pythond: advanced concepts

Aaa ped-2- Python: Basics
Aaa ped-2- Python: BasicsAaa ped-2- Python: Basics
Aaa ped-2- Python: BasicsAminaRepo
 
Python iteration
Python iterationPython iteration
Python iterationdietbuddha
 
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdfProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdflailoesakhan
 
Python Interview Questions And Answers
Python Interview Questions And AnswersPython Interview Questions And Answers
Python Interview Questions And AnswersH2Kinfosys
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methodsPranavSB
 
Functional Programming.pptx
Functional Programming.pptxFunctional Programming.pptx
Functional Programming.pptxKarthickT28
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxRohitKumar639388
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.supriyasarkar38
 
Top Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdfTop Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdfDatacademy.ai
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptxNileshBorkar12
 
ProgFund_Lecture_5_Recap_and_Case_Study-1.pdf
ProgFund_Lecture_5_Recap_and_Case_Study-1.pdfProgFund_Lecture_5_Recap_and_Case_Study-1.pdf
ProgFund_Lecture_5_Recap_and_Case_Study-1.pdflailoesakhan
 
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdfProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdflailoesakhan
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...DRVaibhavmeshram1
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxcargillfilberto
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxdrandy1
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxmonicafrancis71118
 

Similaire à Aaa ped-3. Pythond: advanced concepts (20)

Aaa ped-2- Python: Basics
Aaa ped-2- Python: BasicsAaa ped-2- Python: Basics
Aaa ped-2- Python: Basics
 
Review Python
Review PythonReview Python
Review Python
 
Python for web security - beginner
Python for web security - beginnerPython for web security - beginner
Python for web security - beginner
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
 
Python iteration
Python iterationPython iteration
Python iteration
 
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdfProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
 
Python Interview Questions And Answers
Python Interview Questions And AnswersPython Interview Questions And Answers
Python Interview Questions And Answers
 
Complexity
ComplexityComplexity
Complexity
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methods
 
Functional Programming.pptx
Functional Programming.pptxFunctional Programming.pptx
Functional Programming.pptx
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptx
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
 
Top Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdfTop Most Python Interview Questions.pdf
Top Most Python Interview Questions.pdf
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptx
 
ProgFund_Lecture_5_Recap_and_Case_Study-1.pdf
ProgFund_Lecture_5_Recap_and_Case_Study-1.pdfProgFund_Lecture_5_Recap_and_Case_Study-1.pdf
ProgFund_Lecture_5_Recap_and_Case_Study-1.pdf
 
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdfProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 

Plus de AminaRepo

Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-23-Artificial Neural Network: Keras and TensorfowAaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-23-Artificial Neural Network: Keras and TensorfowAminaRepo
 
Aaa ped-22-Artificial Neural Network: Introduction to ANN
Aaa ped-22-Artificial Neural Network: Introduction to ANNAaa ped-22-Artificial Neural Network: Introduction to ANN
Aaa ped-22-Artificial Neural Network: Introduction to ANNAminaRepo
 
Aaa ped-21-Recommender Systems: Content-based Filtering
Aaa ped-21-Recommender Systems: Content-based FilteringAaa ped-21-Recommender Systems: Content-based Filtering
Aaa ped-21-Recommender Systems: Content-based FilteringAminaRepo
 
Aaa ped-20-Recommender Systems: Model-based collaborative filtering
Aaa ped-20-Recommender Systems: Model-based collaborative filteringAaa ped-20-Recommender Systems: Model-based collaborative filtering
Aaa ped-20-Recommender Systems: Model-based collaborative filteringAminaRepo
 
Aaa ped-19-Recommender Systems: Neighborhood-based Filtering
Aaa ped-19-Recommender Systems: Neighborhood-based FilteringAaa ped-19-Recommender Systems: Neighborhood-based Filtering
Aaa ped-19-Recommender Systems: Neighborhood-based FilteringAminaRepo
 
Aaa ped-18-Unsupervised Learning: Association Rule Learning
Aaa ped-18-Unsupervised Learning: Association Rule LearningAaa ped-18-Unsupervised Learning: Association Rule Learning
Aaa ped-18-Unsupervised Learning: Association Rule LearningAminaRepo
 
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAminaRepo
 
Aaa ped-16-Unsupervised Learning: clustering
Aaa ped-16-Unsupervised Learning: clusteringAaa ped-16-Unsupervised Learning: clustering
Aaa ped-16-Unsupervised Learning: clusteringAminaRepo
 
Aaa ped-15-Ensemble Learning: Random Forests
Aaa ped-15-Ensemble Learning: Random ForestsAaa ped-15-Ensemble Learning: Random Forests
Aaa ped-15-Ensemble Learning: Random ForestsAminaRepo
 
Aaa ped-14-Ensemble Learning: About Ensemble Learning
Aaa ped-14-Ensemble Learning: About Ensemble LearningAaa ped-14-Ensemble Learning: About Ensemble Learning
Aaa ped-14-Ensemble Learning: About Ensemble LearningAminaRepo
 
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes ClassiferAaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes ClassiferAminaRepo
 
Aaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
Aaa ped-11-Supervised Learning: Multivariable Regressor & ClassifersAaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
Aaa ped-11-Supervised Learning: Multivariable Regressor & ClassifersAminaRepo
 
Aaa ped-10-Supervised Learning: Introduction to Supervised Learning
Aaa ped-10-Supervised Learning: Introduction to Supervised LearningAaa ped-10-Supervised Learning: Introduction to Supervised Learning
Aaa ped-10-Supervised Learning: Introduction to Supervised LearningAminaRepo
 
Aaa ped-9-Data manipulation: Time Series & Geographical visualization
Aaa ped-9-Data manipulation: Time Series & Geographical visualizationAaa ped-9-Data manipulation: Time Series & Geographical visualization
Aaa ped-9-Data manipulation: Time Series & Geographical visualizationAminaRepo
 
Aaa ped-Data-8- manipulation: Plotting and Visualization
Aaa ped-Data-8- manipulation: Plotting and VisualizationAaa ped-Data-8- manipulation: Plotting and Visualization
Aaa ped-Data-8- manipulation: Plotting and VisualizationAminaRepo
 
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operationsAaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operationsAminaRepo
 
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & Preparation
Aaa ped-6-Data manipulation:  Data Files, and Data Cleaning & PreparationAaa ped-6-Data manipulation:  Data Files, and Data Cleaning & Preparation
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & PreparationAminaRepo
 
Aaa ped-5-Data manipulation: Pandas
Aaa ped-5-Data manipulation: Pandas Aaa ped-5-Data manipulation: Pandas
Aaa ped-5-Data manipulation: Pandas AminaRepo
 
Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy AminaRepo
 
Aaa ped-1- Python: Introduction to AI, Python and Colab
Aaa ped-1- Python: Introduction to AI, Python and ColabAaa ped-1- Python: Introduction to AI, Python and Colab
Aaa ped-1- Python: Introduction to AI, Python and ColabAminaRepo
 

Plus de AminaRepo (20)

Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-23-Artificial Neural Network: Keras and TensorfowAaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
 
Aaa ped-22-Artificial Neural Network: Introduction to ANN
Aaa ped-22-Artificial Neural Network: Introduction to ANNAaa ped-22-Artificial Neural Network: Introduction to ANN
Aaa ped-22-Artificial Neural Network: Introduction to ANN
 
Aaa ped-21-Recommender Systems: Content-based Filtering
Aaa ped-21-Recommender Systems: Content-based FilteringAaa ped-21-Recommender Systems: Content-based Filtering
Aaa ped-21-Recommender Systems: Content-based Filtering
 
Aaa ped-20-Recommender Systems: Model-based collaborative filtering
Aaa ped-20-Recommender Systems: Model-based collaborative filteringAaa ped-20-Recommender Systems: Model-based collaborative filtering
Aaa ped-20-Recommender Systems: Model-based collaborative filtering
 
Aaa ped-19-Recommender Systems: Neighborhood-based Filtering
Aaa ped-19-Recommender Systems: Neighborhood-based FilteringAaa ped-19-Recommender Systems: Neighborhood-based Filtering
Aaa ped-19-Recommender Systems: Neighborhood-based Filtering
 
Aaa ped-18-Unsupervised Learning: Association Rule Learning
Aaa ped-18-Unsupervised Learning: Association Rule LearningAaa ped-18-Unsupervised Learning: Association Rule Learning
Aaa ped-18-Unsupervised Learning: Association Rule Learning
 
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
 
Aaa ped-16-Unsupervised Learning: clustering
Aaa ped-16-Unsupervised Learning: clusteringAaa ped-16-Unsupervised Learning: clustering
Aaa ped-16-Unsupervised Learning: clustering
 
Aaa ped-15-Ensemble Learning: Random Forests
Aaa ped-15-Ensemble Learning: Random ForestsAaa ped-15-Ensemble Learning: Random Forests
Aaa ped-15-Ensemble Learning: Random Forests
 
Aaa ped-14-Ensemble Learning: About Ensemble Learning
Aaa ped-14-Ensemble Learning: About Ensemble LearningAaa ped-14-Ensemble Learning: About Ensemble Learning
Aaa ped-14-Ensemble Learning: About Ensemble Learning
 
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes ClassiferAaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
 
Aaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
Aaa ped-11-Supervised Learning: Multivariable Regressor & ClassifersAaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
Aaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
 
Aaa ped-10-Supervised Learning: Introduction to Supervised Learning
Aaa ped-10-Supervised Learning: Introduction to Supervised LearningAaa ped-10-Supervised Learning: Introduction to Supervised Learning
Aaa ped-10-Supervised Learning: Introduction to Supervised Learning
 
Aaa ped-9-Data manipulation: Time Series & Geographical visualization
Aaa ped-9-Data manipulation: Time Series & Geographical visualizationAaa ped-9-Data manipulation: Time Series & Geographical visualization
Aaa ped-9-Data manipulation: Time Series & Geographical visualization
 
Aaa ped-Data-8- manipulation: Plotting and Visualization
Aaa ped-Data-8- manipulation: Plotting and VisualizationAaa ped-Data-8- manipulation: Plotting and Visualization
Aaa ped-Data-8- manipulation: Plotting and Visualization
 
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operationsAaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
 
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & Preparation
Aaa ped-6-Data manipulation:  Data Files, and Data Cleaning & PreparationAaa ped-6-Data manipulation:  Data Files, and Data Cleaning & Preparation
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & Preparation
 
Aaa ped-5-Data manipulation: Pandas
Aaa ped-5-Data manipulation: Pandas Aaa ped-5-Data manipulation: Pandas
Aaa ped-5-Data manipulation: Pandas
 
Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy
 
Aaa ped-1- Python: Introduction to AI, Python and Colab
Aaa ped-1- Python: Introduction to AI, Python and ColabAaa ped-1- Python: Introduction to AI, Python and Colab
Aaa ped-1- Python: Introduction to AI, Python and Colab
 

Dernier

Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSarthak Sekhar Mondal
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisDiwakar Mishra
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...anilsa9823
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |aasikanpl
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfSumit Kumar yadav
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Sérgio Sacani
 
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCEPRINCE C P
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 sciencefloriejanemacaya1
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxkessiyaTpeter
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhousejana861314
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...jana861314
 
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptxanandsmhk
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxAArockiyaNisha
 

Dernier (20)

Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 science
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhouse
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
 

Aaa ped-3. Pythond: advanced concepts

  • 1. Python: Data structures, control foo, OO Programming, Regular Expressions, System Programming AAA-Python Edition
  • 2. Plan ● 1- if / else , For, While ● 2- Lists, Tuples, List comprehensions ● 3- Dictionaries ● 4- Sets ● 5- Object Oriented Programming ● 6- Regular Expression ● 7- System Programming
  • 3. 3 1-1-if/else,For,While [By Amina Delali] If / else ● These statements are used to control ohich block of code to execute: If the “condition” is true (the corresponding expression Is Evaluated to True), then the if “clause” is executed (the if block) The condition was false, so The “else” clause was executed The “elif” clause is executed, If its condition is true
  • 4. 4 1-1-if/else,For,While [By Amina Delali] While ● This statement is used to control hoo many times a block of code has to be executed: While the condition is true, the block code will be executed. In this loop, the block has been executed 2 times
  • 5. 5 1-1-if/else,For,While [By Amina Delali] For ● This statement is used to execute a block of code a certain number of times “i” will take its values from the numbers created by the ‘range’ function This “range” function: will generate a range of numbers from “0” to “4-1” This loop will be executed 4 times
  • 6. 6 2-Lists,Tuples, Listcomprehensions [By Amina Delali] List ● A list is a value that contains multiple values. l1 and l2 are lists Tuple A a tuple is a list of immutable values. t1 and t2 are tuples Function “list” to create a list
  • 7. 7 2-Lists,Tuples, Listcomprehensions [By Amina Delali] Lists and tuples (suite) Access to the first element Modifying the value of the element of index 0 (first element) Trying to modify the value of an element of a tuple
  • 8. 8 2-Lists,Tuples, Listcomprehensions [By Amina Delali] Some operations with lists Concatenating two lists a slice: values From index 2 to index 4 Number of elements of a list
  • 9. 9 2-Lists,Tuples, Listcomprehensions [By Amina Delali] Some operations with lists (suite) “not” with “in” Iterate through list Functions “min” and “max” Affecting list values To multiple variables
  • 10. 10 2-Lists,Tuples, Listcomprehensions [By Amina Delali] List comprehensions Filtering elements Creating new elements from range List of lists using 3 loops
  • 11. 11 2-Lists,Tuples, Listcomprehensions [By Amina Delali] List methods Finding an element in a list ● A list has some methods. We will talk about methods later. Add an element to the end of a list Insert an element at a certain position Remove an element from a list
  • 12. 12 3-Dictionaries [By Amina Delali] ● Dictionaries ● A dictionary is a list of values with corresponding keys key Value Method that returns the dictionary values Value Method that returns the dictionary keys
  • 13. 13 3-Dictionaries [By Amina Delali] ● Dictionaries (suite) Method that returns the dictionary items: pairs of key,value The key doesn’t exist so a default value is given The key exists, its value Is returned A key is created with a default value The key already exists, So no other key is created
  • 14. 14 4-Sets [By Amina Delali] Sets ● A set is a list of distinct values The duplicates are eliminated Is s1 a subset of s2 Elements in S1 and not in s2 Intersection between s1 and s2
  • 15. 15 5-ObjectOriented Programming [By Amina Delali] Classes ● In Python, we can defne “classes”: a defned prototype that encapsulates data and the functions to operate on them. ● An instance of a class is called an “object”. We already used objects when we used lists, sets and dictionaries. Name of the class Data attribute A method (a function attribute) To indicate that elements of range are not the elements of the list Called when creating an object of that class
  • 16. 16 5-ObjectOriented Programming [By Amina Delali] Classes A comment Optional attribute for function print Each time we use myList, we ensure that length== len(myList)
  • 17. 17 5-ObjectOriented Programming [By Amina Delali] Classes A subclass of class MyTable Inherits all its methods and data attributes: We can use them without redefining them. Redefine “myType” (already defined in MyTable) It’s overriding myType parent class methodObject creation( Call of __init__) Call of a method Access of a data attribute
  • 18. 18 5-ObjectOriented Programming [By Amina Delali] Classes Same class, different values c an instance of MyTable2: Use of __init__ method of class MyTable An other different subclass List of 4 instances of different classes Call of the same Method had different results == Polymorphism
  • 19. 19 6-Regularexpressions [By Amina Delali] Regular expressions ● A regular expression is a description of pattern of text A year from 1970 to 2999 A month: composed of: 0 and a digit from 1 to 9 (0[1-9]) Or (|) 1 and a digit from 0 to 2 (1[0-2]) Search a pattern at the start One or more a(+) Search for the first date 3 digits Need of module re
  • 20. 20 7-System programming [By Amina Delali] System Programming ● We will focus on system programming in Colab. ● Some Python functions can be simply done on Colab. ● For example the bash commands: they can be used as they are by prefxing them by “!” or “%”: !ls, !mkdir, !git, !pip, %cd … etc Running ‘ls’ using subprocess Import a local file After selecting the Script file, import it
  • 21. 21 7-System programming [By Amina Delali] System Programming ● Second way of using a user defned script: ● We have to mount Google Drive Using a defined function Running the file as a script To avoid using the full path of the script, use sys.path.append
  • 22. 22 7-System programming [By Amina Delali] System Programming Using ‘!cat’ to print the content of the file Creating the file path Open and read the file content into a list Print the list Use if__name__ ==”__main__” for the code To be executed if the module is not imported And run as a script
  • 23. References ● Duchesnay Edouard and Löfstedt Tommy. Statistics and machine learning in python release 0.2. On-line at ftp://ftp.cea.fr/pub/unati/people/educhesnay/pystatml/M1_IMSV/StatisticsMachineL earningPythonDraft.pdf. Accessed on 23-09-2018. ● Python Software Foundation. The python standard library. On-line at https://docs.python.org/3.6/library/index.html. Accessed on 23-09-2018. ● Joel Grus. Data science from scratch: frst principles with python. O’Reilly Media, Inc, 2015. ● Chandat Sunny. Learn Python in 24 Hours. CreateSpace Independent Publishing Platform, 2016. ● Al Sweigart. Automate the boring stuf with Python: practical programming for total beginners. No Starch Press, 2015.