SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Formation Python
C ’EST PYTHON?
SYNTAXE
BOUCLES
FONCTIONS, MODULES
1SMAHI Zakaria 29/11/2014
Plan de formation
 C’est quoi Python ?
 Pourquoi Python ?
 Domaines d’application
 Utilisation de python
 IDEs
 Hello World!
 Variables et Types
 Statements (Condition, boucles, gestions des exceptions …etc. )
 Fonctions, Modules
2
C’est quoi Python ?
 Python est un langage de programmation.
 Python est développé en 1989 et il est toujours en développement.
 Inspiré de Plusieurs langages de programmation.
 Caractéristiques similaires au Java et Perl.
 D’autres langages : C++, Haskell, ADA.
 Site officiel : http://www.python.org
3
Pourquoi Python ?
 Python est portable et multiplateforme.
 Python est gratuit.
 Python est utilisé pour le Scripting et le développement Desktop ou Web.
 Syntaxe trop simple et lisible.
 Manipulation automatique de la mémoire, pas de notions de pointeurs.
 Python est; optionnellement; multithreading est Orienté Objet.
 Python a un système efficace pour la gestion des exceptions.
 Python est riche en terme de bibliothèques.
4
Domaines d’application
 Programmation Orienté Objet.
 Programmation Fonctionnelle et Logique
 Administration Système.
 Analyse du texte et de l’écrit.
 Développement web et Desktop.
 Bases de données.
 Recherche scientifique.
 Calcul scientifique.
 Rendu graphique Blender.
 Prototypage rapide des applications
5
Utilisation de Python
 Utiliser IDLE Python:
 Editer un script.
 Le mode interactif.
 exécuter un script python.
 Téléchargeable avec Python
 $ sudo apt-get install idle.
 $ sudo yum install.
 $ python monScript.py
 $ python # mode interactif
 D’autres Shell interactif : IPython, bpython
6
Editeurs et IDE
 Notepad ++.
 Sublime Text.
 Gedit (Gnome).
 Kate/Kwrite (KDE).
 Geany
 Eclipce PyDev / Aptana Pydev
 Pycharm
7
Hello World!
 print ‘Hello world!’
 Commentaire:
 # Ceci est un commentaire
 ‘’ ‘’ ‘’ ceci est un commentaire
multilingue .’’ ‘’ ‘’
 name = raw_input(‘Your Name
please ’)
 print ‘Hello’,name
8
Variables et Types
 Les variables sont sensibles à la casse.
 Autocréation des variables.
 Autodétermination du type.
 Une variable peut être réassignée to WHATEVER et WHENEVER.
>> n = 12
>> print n
>> type (n)
>> n = ‘chaine’
>> print n
>> type(n)
9
Variables et Types -> Nombres
 Integers : 25, 0, (-8), 0123, 0X20
 Float: 91.08, 2E91 , -5 E -93
 Long Integers: 10294L
 Nombre Complexes: 1-2j
 Opérations arithmétiques : +,-,*,/,**,%,//.
 Changement de type vers un autres => x = 4 ; float(x) -> 4.0
152 + 8
15/4
15.0/3
13**2
10
Variables et Types -> Booléens
 True et False sont utilisés
 0 et ‘’ sont considérés comme False
 Les autres sont True
 Opérations logiques : not, and, or.
True or False
not True
True and False
11
Variables et Types -> Strings
 a = 'Hello World'
 b = "Hello world"
 a == b
 n , t
 " " " ceci est un commentaire trop long " " "
a = ' une ligne n une autre ligne t maintenant une tabulation '
12
Variables et Types -> Strings -> Opérations
 a = 'Chaine 1'
 b = "Chaine 2"
 a +' '+b
 s = a * 3
 s[0] ## index on commence à
partir du 0.
 s[-1] ## dernier élément.
13
 s[0:4:1]
 s[4:]
 s[:-1]
 len(s)
 'p' in S
 'Chaine' in S
 S[0] = 'b' ?
Variables et Types -> Strings -> Méthodes
 a.count('a')
 a.find('chaine')
 trois = '3'
 trois.isdigit()
14
 a.upper()
 b.lower()
 a.replace('ch','3')
 a.replace('ch','3',1)
Variables et Types -> List
 Collection ordonnée des objets.
 Array.
 [], index initial 0
 l = [1,2.0,'3'] # possibilité d’avoir plusieurs types dans la même liste.
 l[2] ; l[-1]; l[1:2]
 l =l + [4, 5]
 append, remove, pop, extend, sort,…etc.
15
Variables et Types -> Tuples
 Les tuples ressemblent aux listes.
 Immutable.
 Certaines fonctions retournent un tuple.
 t = (1,2,3).
 a,b = b,a.
16
Variables et Types -> Dictionary
 Une liste non-ordonnée de paires : (clés,valeurs).
 d = {‘key1’:1,’key2’:2}
 d.keys(), d.values()
 D’autres fonctions
17
Statements-> If-Else
 If condition :
« »code
else :
« »codeElse
« » = tab ou 4 espace = indentation.
 if condition:
« »code
elif uneAutreCondition:
« »codeElif
Else :
« » CodeElse
18
Statements-> Boucles
 for item in list:
« »CodeIteratif
 for item in range():
« »CodeIteratif
 for item in xrange:
« »CodeIteratif
 While Condition:
« »CodeWhile
19
Statements-> Try-Except
 Try :
code
Except value:
Code
numbers = []
not_numbers = []
for s in ['12', '-4.1', '1.0e2', 'e3']:
try:
n = float(s)
numbers.append(s)
except ValueError, msg:
not_numbers.append(str(msg))
print 'numbers:', numbers
print 'not numbers:', not_numbers
20
Statements-> Autres
 Finally,
 Yield,
 raise,
 global,
 exec,
 goto n’existe pas
21
Fonctions
 Utiliser le mot def
 def function(parametres):
code
[return]
22
Modules
 Le mot import
 Modules math, re,
 Des exemples.
23
24
QUESTIONS ?
25
Merci pour votre attention !

Weitere ähnliche Inhalte

Was ist angesagt?

Chap3 programmation modulaire en python
Chap3 programmation modulaire en pythonChap3 programmation modulaire en python
Chap3 programmation modulaire en pythonMariem ZAOUALI
 
Chapitre 2: String en Java
Chapitre 2:  String en JavaChapitre 2:  String en Java
Chapitre 2: String en JavaAziz Darouichi
 
Programming language python 2021
Programming language python 2021Programming language python 2021
Programming language python 2021Dalila Chouaya
 
Chap1 Introduction à python
Chap1 Introduction à pythonChap1 Introduction à python
Chap1 Introduction à pythonMariem ZAOUALI
 
Chapitre8: Collections et Enumerations En Java
Chapitre8: Collections et Enumerations En JavaChapitre8: Collections et Enumerations En Java
Chapitre8: Collections et Enumerations En JavaAziz Darouichi
 
Chapitre1: Langage Python
Chapitre1: Langage PythonChapitre1: Langage Python
Chapitre1: Langage PythonAziz Darouichi
 
cpp1 : Quelques elements de base du C++
cpp1 : Quelques elements de base du C++cpp1 : Quelques elements de base du C++
cpp1 : Quelques elements de base du C++Abdoulaye Dieng
 
Introduction a la compilation Analyse lexicale - C2
Introduction a la compilation  Analyse lexicale - C2Introduction a la compilation  Analyse lexicale - C2
Introduction a la compilation Analyse lexicale - C2Beligh HAMDI
 
Les fondamentaux du langage C
Les fondamentaux du langage CLes fondamentaux du langage C
Les fondamentaux du langage CAbdoulaye Dieng
 
Python avancé : Ensemble, dictionnaire et base de données
Python avancé : Ensemble, dictionnaire et base de donnéesPython avancé : Ensemble, dictionnaire et base de données
Python avancé : Ensemble, dictionnaire et base de donnéesECAM Brussels Engineering School
 
Les concepts de la programmation fonctionnelle illustrés avec Java 8
Les concepts de la programmation fonctionnelle illustrés avec Java 8Les concepts de la programmation fonctionnelle illustrés avec Java 8
Les concepts de la programmation fonctionnelle illustrés avec Java 8Yannick Chartois
 
Introduction a la compilation Analyse Syntaxique - C3
Introduction a la compilation  Analyse Syntaxique - C3Introduction a la compilation  Analyse Syntaxique - C3
Introduction a la compilation Analyse Syntaxique - C3Beligh HAMDI
 
Initiation à l'algorithmique
Initiation à l'algorithmiqueInitiation à l'algorithmique
Initiation à l'algorithmiqueAbdoulaye Dieng
 
Initiation à l'algorithmique
Initiation à l'algorithmiqueInitiation à l'algorithmique
Initiation à l'algorithmiqueAbdoulaye Dieng
 

Was ist angesagt? (20)

Chap3 programmation modulaire en python
Chap3 programmation modulaire en pythonChap3 programmation modulaire en python
Chap3 programmation modulaire en python
 
Chapitre 2: String en Java
Chapitre 2:  String en JavaChapitre 2:  String en Java
Chapitre 2: String en Java
 
Formation python 3
Formation python 3Formation python 3
Formation python 3
 
Programming language python 2021
Programming language python 2021Programming language python 2021
Programming language python 2021
 
Chap1 Introduction à python
Chap1 Introduction à pythonChap1 Introduction à python
Chap1 Introduction à python
 
Chapitre8: Collections et Enumerations En Java
Chapitre8: Collections et Enumerations En JavaChapitre8: Collections et Enumerations En Java
Chapitre8: Collections et Enumerations En Java
 
Cours php
Cours phpCours php
Cours php
 
Chapitre1: Langage Python
Chapitre1: Langage PythonChapitre1: Langage Python
Chapitre1: Langage Python
 
Formation python
Formation pythonFormation python
Formation python
 
cpp1 : Quelques elements de base du C++
cpp1 : Quelques elements de base du C++cpp1 : Quelques elements de base du C++
cpp1 : Quelques elements de base du C++
 
Introduction a la compilation Analyse lexicale - C2
Introduction a la compilation  Analyse lexicale - C2Introduction a la compilation  Analyse lexicale - C2
Introduction a la compilation Analyse lexicale - C2
 
Les fondamentaux du langage C
Les fondamentaux du langage CLes fondamentaux du langage C
Les fondamentaux du langage C
 
Python avancé : Ensemble, dictionnaire et base de données
Python avancé : Ensemble, dictionnaire et base de donnéesPython avancé : Ensemble, dictionnaire et base de données
Python avancé : Ensemble, dictionnaire et base de données
 
Les concepts de la programmation fonctionnelle illustrés avec Java 8
Les concepts de la programmation fonctionnelle illustrés avec Java 8Les concepts de la programmation fonctionnelle illustrés avec Java 8
Les concepts de la programmation fonctionnelle illustrés avec Java 8
 
Les listes en Python
Les listes en PythonLes listes en Python
Les listes en Python
 
Introduction a la compilation Analyse Syntaxique - C3
Introduction a la compilation  Analyse Syntaxique - C3Introduction a la compilation  Analyse Syntaxique - C3
Introduction a la compilation Analyse Syntaxique - C3
 
Introduction à Python
Introduction à PythonIntroduction à Python
Introduction à Python
 
Initiation à l'algorithmique
Initiation à l'algorithmiqueInitiation à l'algorithmique
Initiation à l'algorithmique
 
Initiation à l'algorithmique
Initiation à l'algorithmiqueInitiation à l'algorithmique
Initiation à l'algorithmique
 
Python avancé : Lecture et écriture de fichiers
Python avancé : Lecture et écriture de fichiersPython avancé : Lecture et écriture de fichiers
Python avancé : Lecture et écriture de fichiers
 

Andere mochten auch

Sécurisation des Web Services SOAP contre les attaques par injection par la m...
Sécurisation des Web Services SOAP contre les attaques par injection par la m...Sécurisation des Web Services SOAP contre les attaques par injection par la m...
Sécurisation des Web Services SOAP contre les attaques par injection par la m...Zakaria SMAHI
 
Sécurité des web services soap
Sécurité des web services soapSécurité des web services soap
Sécurité des web services soapZakaria SMAHI
 
Buffer Overflow exploitation
Buffer Overflow exploitationBuffer Overflow exploitation
Buffer Overflow exploitationZakaria SMAHI
 
Guide d'utilisation de nmap par smahi zakaria
Guide d'utilisation de nmap par smahi zakariaGuide d'utilisation de nmap par smahi zakaria
Guide d'utilisation de nmap par smahi zakariaZakaria SMAHI
 
workshop initiation ssh
workshop initiation sshworkshop initiation ssh
workshop initiation sshZakaria SMAHI
 
Securisation des web services soap contre les attaques par injection
Securisation des web services soap contre les attaques par injectionSecurisation des web services soap contre les attaques par injection
Securisation des web services soap contre les attaques par injectionZakaria SMAHI
 
تجربتي مع المساهمة في المشاريع الحرة - اليوم الحر
تجربتي مع المساهمة  في المشاريع الحرة - اليوم الحر تجربتي مع المساهمة  في المشاريع الحرة - اليوم الحر
تجربتي مع المساهمة في المشاريع الحرة - اليوم الحر Assem CHELLI
 

Andere mochten auch (12)

Sécurisation des Web Services SOAP contre les attaques par injection par la m...
Sécurisation des Web Services SOAP contre les attaques par injection par la m...Sécurisation des Web Services SOAP contre les attaques par injection par la m...
Sécurisation des Web Services SOAP contre les attaques par injection par la m...
 
Owasp webgoat
Owasp webgoatOwasp webgoat
Owasp webgoat
 
Bootstrap 3
Bootstrap 3Bootstrap 3
Bootstrap 3
 
Javascript 2.0
Javascript 2.0 Javascript 2.0
Javascript 2.0
 
Sécurité des web services soap
Sécurité des web services soapSécurité des web services soap
Sécurité des web services soap
 
Buffer Overflow exploitation
Buffer Overflow exploitationBuffer Overflow exploitation
Buffer Overflow exploitation
 
Guide d'utilisation de nmap par smahi zakaria
Guide d'utilisation de nmap par smahi zakariaGuide d'utilisation de nmap par smahi zakaria
Guide d'utilisation de nmap par smahi zakaria
 
workshop initiation ssh
workshop initiation sshworkshop initiation ssh
workshop initiation ssh
 
Securisation des web services soap contre les attaques par injection
Securisation des web services soap contre les attaques par injectionSecurisation des web services soap contre les attaques par injection
Securisation des web services soap contre les attaques par injection
 
Javascript 1.0
Javascript 1.0 Javascript 1.0
Javascript 1.0
 
تجربتي مع المساهمة في المشاريع الحرة - اليوم الحر
تجربتي مع المساهمة  في المشاريع الحرة - اليوم الحر تجربتي مع المساهمة  في المشاريع الحرة - اليوم الحر
تجربتي مع المساهمة في المشاريع الحرة - اليوم الحر
 
JQuery
JQueryJQuery
JQuery
 

Ähnlich wie Formation python micro club.net

FormationPython2019.pptx
FormationPython2019.pptxFormationPython2019.pptx
FormationPython2019.pptxLamissGhoul1
 
Data Mining (Partie 2).pdf
Data Mining (Partie 2).pdfData Mining (Partie 2).pdf
Data Mining (Partie 2).pdfOuailChoukhairi
 
Développement Web- PHP (partie I).pdf
Développement Web- PHP (partie I).pdfDéveloppement Web- PHP (partie I).pdf
Développement Web- PHP (partie I).pdfYasushiTsubakik
 
Formation en Python_Niveau1_2023.pptx
Formation en Python_Niveau1_2023.pptxFormation en Python_Niveau1_2023.pptx
Formation en Python_Niveau1_2023.pptxbetalab
 
M2 INAE introduction python.pdf
M2 INAE introduction python.pdfM2 INAE introduction python.pdf
M2 INAE introduction python.pdfHajer Amdouni
 
intro-csharp developement master 2 IF APP
intro-csharp developement master 2 IF APPintro-csharp developement master 2 IF APP
intro-csharp developement master 2 IF APPfrwebhelp
 
Chap 1 Initiation.pptx
Chap 1 Initiation.pptxChap 1 Initiation.pptx
Chap 1 Initiation.pptxolfaharrabi2
 
Redis - (nosqlfr meetup #2)
Redis - (nosqlfr meetup #2) Redis - (nosqlfr meetup #2)
Redis - (nosqlfr meetup #2) Frank Denis
 
Eléments du langage Java.pdf
Eléments du langage  Java.pdfEléments du langage  Java.pdf
Eléments du langage Java.pdfAabidiHafid
 
Introduction à scala
Introduction à scalaIntroduction à scala
Introduction à scalaSOAT
 
Python For Data Science - French Course
Python For Data Science - French CoursePython For Data Science - French Course
Python For Data Science - French CourseHaytam EL YOUSSFI
 
Développement informatique : Chaines de caractères et expressions regulières
Développement informatique : Chaines de caractères et expressions regulièresDéveloppement informatique : Chaines de caractères et expressions regulières
Développement informatique : Chaines de caractères et expressions regulièresECAM Brussels Engineering School
 
Formation python
Formation pythonFormation python
Formation pythonj_lipaz
 
01 - Introduction à Python chaines de caractères.pdf
01 - Introduction à Python chaines de caractères.pdf01 - Introduction à Python chaines de caractères.pdf
01 - Introduction à Python chaines de caractères.pdfMARYAM510573
 

Ähnlich wie Formation python micro club.net (20)

COURS_PYTHON_22.ppt
COURS_PYTHON_22.pptCOURS_PYTHON_22.ppt
COURS_PYTHON_22.ppt
 
FormationPython2019.pptx
FormationPython2019.pptxFormationPython2019.pptx
FormationPython2019.pptx
 
Data Mining (Partie 2).pdf
Data Mining (Partie 2).pdfData Mining (Partie 2).pdf
Data Mining (Partie 2).pdf
 
Développement Web- PHP (partie I).pdf
Développement Web- PHP (partie I).pdfDéveloppement Web- PHP (partie I).pdf
Développement Web- PHP (partie I).pdf
 
Formation en Python_Niveau1_2023.pptx
Formation en Python_Niveau1_2023.pptxFormation en Python_Niveau1_2023.pptx
Formation en Python_Niveau1_2023.pptx
 
langage C++
langage C++langage C++
langage C++
 
M2 INAE introduction python.pdf
M2 INAE introduction python.pdfM2 INAE introduction python.pdf
M2 INAE introduction python.pdf
 
intro-csharp developement master 2 IF APP
intro-csharp developement master 2 IF APPintro-csharp developement master 2 IF APP
intro-csharp developement master 2 IF APP
 
Chap 1 Initiation.pptx
Chap 1 Initiation.pptxChap 1 Initiation.pptx
Chap 1 Initiation.pptx
 
Redis - (nosqlfr meetup #2)
Redis - (nosqlfr meetup #2) Redis - (nosqlfr meetup #2)
Redis - (nosqlfr meetup #2)
 
Eléments du langage Java.pdf
Eléments du langage  Java.pdfEléments du langage  Java.pdf
Eléments du langage Java.pdf
 
Introduction à scala
Introduction à scalaIntroduction à scala
Introduction à scala
 
Python For Data Science - French Course
Python For Data Science - French CoursePython For Data Science - French Course
Python For Data Science - French Course
 
Développement informatique : Chaines de caractères et expressions regulières
Développement informatique : Chaines de caractères et expressions regulièresDéveloppement informatique : Chaines de caractères et expressions regulières
Développement informatique : Chaines de caractères et expressions regulières
 
Formation python
Formation pythonFormation python
Formation python
 
01 - Introduction à Python chaines de caractères.pdf
01 - Introduction à Python chaines de caractères.pdf01 - Introduction à Python chaines de caractères.pdf
01 - Introduction à Python chaines de caractères.pdf
 
Audits php
Audits phpAudits php
Audits php
 
Csharp2014
Csharp2014Csharp2014
Csharp2014
 
Php4 Mysql
Php4 MysqlPhp4 Mysql
Php4 Mysql
 
Algo inf102 2007
Algo inf102 2007Algo inf102 2007
Algo inf102 2007
 

Formation python micro club.net

  • 1. Formation Python C ’EST PYTHON? SYNTAXE BOUCLES FONCTIONS, MODULES 1SMAHI Zakaria 29/11/2014
  • 2. Plan de formation  C’est quoi Python ?  Pourquoi Python ?  Domaines d’application  Utilisation de python  IDEs  Hello World!  Variables et Types  Statements (Condition, boucles, gestions des exceptions …etc. )  Fonctions, Modules 2
  • 3. C’est quoi Python ?  Python est un langage de programmation.  Python est développé en 1989 et il est toujours en développement.  Inspiré de Plusieurs langages de programmation.  Caractéristiques similaires au Java et Perl.  D’autres langages : C++, Haskell, ADA.  Site officiel : http://www.python.org 3
  • 4. Pourquoi Python ?  Python est portable et multiplateforme.  Python est gratuit.  Python est utilisé pour le Scripting et le développement Desktop ou Web.  Syntaxe trop simple et lisible.  Manipulation automatique de la mémoire, pas de notions de pointeurs.  Python est; optionnellement; multithreading est Orienté Objet.  Python a un système efficace pour la gestion des exceptions.  Python est riche en terme de bibliothèques. 4
  • 5. Domaines d’application  Programmation Orienté Objet.  Programmation Fonctionnelle et Logique  Administration Système.  Analyse du texte et de l’écrit.  Développement web et Desktop.  Bases de données.  Recherche scientifique.  Calcul scientifique.  Rendu graphique Blender.  Prototypage rapide des applications 5
  • 6. Utilisation de Python  Utiliser IDLE Python:  Editer un script.  Le mode interactif.  exécuter un script python.  Téléchargeable avec Python  $ sudo apt-get install idle.  $ sudo yum install.  $ python monScript.py  $ python # mode interactif  D’autres Shell interactif : IPython, bpython 6
  • 7. Editeurs et IDE  Notepad ++.  Sublime Text.  Gedit (Gnome).  Kate/Kwrite (KDE).  Geany  Eclipce PyDev / Aptana Pydev  Pycharm 7
  • 8. Hello World!  print ‘Hello world!’  Commentaire:  # Ceci est un commentaire  ‘’ ‘’ ‘’ ceci est un commentaire multilingue .’’ ‘’ ‘’  name = raw_input(‘Your Name please ’)  print ‘Hello’,name 8
  • 9. Variables et Types  Les variables sont sensibles à la casse.  Autocréation des variables.  Autodétermination du type.  Une variable peut être réassignée to WHATEVER et WHENEVER. >> n = 12 >> print n >> type (n) >> n = ‘chaine’ >> print n >> type(n) 9
  • 10. Variables et Types -> Nombres  Integers : 25, 0, (-8), 0123, 0X20  Float: 91.08, 2E91 , -5 E -93  Long Integers: 10294L  Nombre Complexes: 1-2j  Opérations arithmétiques : +,-,*,/,**,%,//.  Changement de type vers un autres => x = 4 ; float(x) -> 4.0 152 + 8 15/4 15.0/3 13**2 10
  • 11. Variables et Types -> Booléens  True et False sont utilisés  0 et ‘’ sont considérés comme False  Les autres sont True  Opérations logiques : not, and, or. True or False not True True and False 11
  • 12. Variables et Types -> Strings  a = 'Hello World'  b = "Hello world"  a == b  n , t  " " " ceci est un commentaire trop long " " " a = ' une ligne n une autre ligne t maintenant une tabulation ' 12
  • 13. Variables et Types -> Strings -> Opérations  a = 'Chaine 1'  b = "Chaine 2"  a +' '+b  s = a * 3  s[0] ## index on commence à partir du 0.  s[-1] ## dernier élément. 13  s[0:4:1]  s[4:]  s[:-1]  len(s)  'p' in S  'Chaine' in S  S[0] = 'b' ?
  • 14. Variables et Types -> Strings -> Méthodes  a.count('a')  a.find('chaine')  trois = '3'  trois.isdigit() 14  a.upper()  b.lower()  a.replace('ch','3')  a.replace('ch','3',1)
  • 15. Variables et Types -> List  Collection ordonnée des objets.  Array.  [], index initial 0  l = [1,2.0,'3'] # possibilité d’avoir plusieurs types dans la même liste.  l[2] ; l[-1]; l[1:2]  l =l + [4, 5]  append, remove, pop, extend, sort,…etc. 15
  • 16. Variables et Types -> Tuples  Les tuples ressemblent aux listes.  Immutable.  Certaines fonctions retournent un tuple.  t = (1,2,3).  a,b = b,a. 16
  • 17. Variables et Types -> Dictionary  Une liste non-ordonnée de paires : (clés,valeurs).  d = {‘key1’:1,’key2’:2}  d.keys(), d.values()  D’autres fonctions 17
  • 18. Statements-> If-Else  If condition : « »code else : « »codeElse « » = tab ou 4 espace = indentation.  if condition: « »code elif uneAutreCondition: « »codeElif Else : « » CodeElse 18
  • 19. Statements-> Boucles  for item in list: « »CodeIteratif  for item in range(): « »CodeIteratif  for item in xrange: « »CodeIteratif  While Condition: « »CodeWhile 19
  • 20. Statements-> Try-Except  Try : code Except value: Code numbers = [] not_numbers = [] for s in ['12', '-4.1', '1.0e2', 'e3']: try: n = float(s) numbers.append(s) except ValueError, msg: not_numbers.append(str(msg)) print 'numbers:', numbers print 'not numbers:', not_numbers 20
  • 21. Statements-> Autres  Finally,  Yield,  raise,  global,  exec,  goto n’existe pas 21
  • 22. Fonctions  Utiliser le mot def  def function(parametres): code [return] 22
  • 23. Modules  Le mot import  Modules math, re,  Des exemples. 23
  • 25. 25 Merci pour votre attention !