SlideShare une entreprise Scribd logo
1  sur  30
Initiation
en programmation Python
Université Mohammed Premier
Ecole Supérieure de Technologie
Oujda
1. Introduction;
2. Type de données en python;
3. Les instructions de bases;
4. Les structures conditionnelles;
5. Les structures répétitives(Les boucles);
6. Les fonctions;
7. Les listes.
Plan
Formation
initiation
en
python
2
 C’est un langage développé par Guido van Rossum en 1991 aux Pays-Bas
 Il est caractérisé par une syntaxe simple, claire et cohérente;
 Il est conçu pour optimiser la productivité des programmeurs en offrant des
outils de haut niveau et une syntaxe simple à utiliser;
 Il permet une initiation aisée aux concepts de base de la programmation;
 On peut utiliser python soit en mode interactif (exécution des instructions en
Shell) ou en mode script (création d’un fichier contenant les instructions de
python).
Introduction
Formation
initiation
en
python
3
Type de données en python
Formation
initiation
en
python
4
Type de données en python
Formation
initiation
en
python
5
Python est un langage typé dynamiquement : le type d’une variable est
déterminé par l’interpréteur au moment de l’exécution et n’a pas besoin d’être
déclaré
Les types simples
Exe,ple int floqt str bool
L'instruction d'affectation
Les instructions de base
Formation
initiation
en
python
6
nomVariable=Expression
La syntaxe:
La lecture l'écriture et en Python
Formation
initiation
en
python
7
L'instruction de lecture en Python( la
saisie)
La fonction input() met le programme en pause et attend de
l’utilisateur un message au clavier (qu’il termine en appuyant sur la
touche "Entrée"). Le message est une chaîne de caractères.
La lecture l'écriture et en Python
Formation
initiation
en
python
8
L'instruction de lecture en Python( la
saisie)
La lecture l'écriture et en Python
Formation
initiation
en
python
9
L'instruction de lecture en Python( la
saisie)
La lecture l'écriture et en Python
Formation
initiation
en
python
10
L'instruction d'écriture en Python(
l'affichage)
La fonction print(chaine1,chaine2,chaine3,...) affiche des chaînes ou
des objets.
Indentation en Python
Formation
initiation
en
python
11
Indenter un code consiste à introduire des espaces ou des
tabulations en début de ligne.
L’indentation est souvent utilisée à des fins esthétiques
mais en Python, elle fait partie de la sémantique.
Indentation en Python
Formation
initiation
en
python
12
•Toutes les instructions au même niveau d’indentation appartiennent
au même bloc.
Les Structures conditionnelles
Formation
initiation
en
python
13
Comme tout langage de programmation, En python, la prise de décision est
effectuée par les instructions suivantes:
Simple: If
Alternative: If - else
Multiple: if imbriquée
Les Structures conditionnelles
Formation
initiation
en
python
14
Si ... alors ...
Voici comment utiliser le test « if » avec Python :
Les Structures conditionnelles
Formation
initiation
en
python
15
Si ... alors ...
Organigramme de la structure à un choix
Les Structures conditionnelles
Formation
initiation
en
python
16
Si ... alors ...
Remarques
 Une condition est une expression booléenne. Elle est soit vraie soit fausse
 Fréquemment, cette condition se présente sous forme de comparaison en
utilisant les opérateurs : <, >, <=, >=, =, <>,....
 La condition est soit "simple", soit "composée". Dans le cas d'une condition
composée, vous utiliserez des opérateurs logiques ; les plus utilisés sont :
and, or, not.
 Le traitement peut comporter une ou plusieurs instructions.
Les Structures conditionnelles
Formation
initiation
en
python
17
Si ... alors ...
Exercice d'application
1) Ecrire un script permettant de résoudre l’équation de 1er degré :ax+b=0
(on suppose que a >0)
2) Ecrire un script qui affiche la valeur absolue d’un réel.
Les Structures conditionnelles
Formation
initiation
en
python
18
Si ... alors ...
Exemples:
Les Structures conditionnelles
Formation
initiation
en
python
19
Si ... alors ...
Exemples:
Les Structures conditionnelles
Formation
initiation
en
python
20
Si ... alors .. Sinon.
Les Structures conditionnelles
Formation
initiation
en
python
21
Si ... alors .. Sinon.
Organigramme de la structure à deux choix
Les Structures conditionnelles
Formation
initiation
en
python
22
Si ... alors .. Sinon.
Exemple:
Les Structures conditionnelles
Formation
initiation
en
python
23
Si ... alors .. Sinon.
Exercice d'application
Ecrire un script permettant de déterminer le maximum de deux nombres
réels saisis par l'utilisateur.
Les Structures conditionnelles
Formation
initiation
en
python
24
Si ... alors .. imbriqués
if condition_1:
instruction_1.1
instruction_1.2
...
elif condition_2:
instruction_2.1
instruction_2.2
...
else:
instruction_n.1
instruction_n.2
...
Les Structures conditionnelles
Formation
initiation
en
python
25
Si ... alors .. imbriqués
Exercice d'application
Ecrire un script qui donne l'état de l'eau selon sa température T:
- Si T<0: état solide;
- Si T>100 : état gazeux
- Si 100<T<0: état liquide
Les Structures répétitives
Formation
initiation
en
python
26
La boucle for
La boucle for est la façon la plus simple de répéter des instructions.
Les Structures répétitives
Formation
initiation
en
python
27
La boucle for
Écrire un script qui permet de calculer et d'afficher le factoriel
d'un nombre entier positif :
Sachant que : 𝑘! = 1 ∗ 2 ∗ 3 ∗. .∗ 𝑘 et 0!=1
Exemple:
5!= 120
Exercice d'application
Les Structures répétitives
Formation
initiation
en
python
28
La boucle while
La boucle while exécute des instructions tant qu’une condition est vraie.
Dès que la condition devient fausse, elle passe aux instructions suivantes.
Les Structures répétitives
Formation
initiation
en
python
29
La boucle while
Réécrire un script qui permet de calculer et d'afficher le factoriel
d'un nombre entier positif :
Sachant que : 𝑘! = 1 ∗ 2 ∗ 3 ∗. .∗ 𝑘 et 0!=1
Exemple:
5!= 120
Exercice d'application
Les Structures répétitives
Formation
initiation
en
python
30
•Toutes les instructions au même niveau d’indentation appartiennent
au même bloc.

Contenu connexe

Similaire à PPT Python.pptx

FormationPython2019.pptx
FormationPython2019.pptxFormationPython2019.pptx
FormationPython2019.pptxLamissGhoul1
 
Algorithmique_et_programmation_part2
Algorithmique_et_programmation_part2Algorithmique_et_programmation_part2
Algorithmique_et_programmation_part2Emeric Tapachès
 
Langage de Programmation.pdf
Langage de Programmation.pdfLangage de Programmation.pdf
Langage de Programmation.pdfAboubacarDiarra10
 
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
 
Chap XIII : calcul scientifique avec python
Chap XIII : calcul scientifique avec pythonChap XIII : calcul scientifique avec python
Chap XIII : calcul scientifique avec pythonMohammed TAMALI
 
Programmation-en-C-ESIITECH-2023-2024-bis.pptx
Programmation-en-C-ESIITECH-2023-2024-bis.pptxProgrammation-en-C-ESIITECH-2023-2024-bis.pptx
Programmation-en-C-ESIITECH-2023-2024-bis.pptxOlyvierNzighou1
 
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
 
Programmation-en-C-ESIITECH-2023-2024.pptx
Programmation-en-C-ESIITECH-2023-2024.pptxProgrammation-en-C-ESIITECH-2023-2024.pptx
Programmation-en-C-ESIITECH-2023-2024.pptxOlyvierNzighou1
 
découverte du langage python dans tous ses aspects
découverte du langage python dans tous ses aspectsdécouverte du langage python dans tous ses aspects
découverte du langage python dans tous ses aspectsThierry Gayet
 
pythonxxzexexzxzexzexzexzxzexezxzexzxz.pdf
pythonxxzexexzxzexzexzexzxzexezxzexzxz.pdfpythonxxzexexzxzexzexzexzxzexezxzexzxz.pdf
pythonxxzexexzxzexzexzexzxzexezxzexzxz.pdfMehdiHarchenifChassa
 
PyConFR - testons en python
PyConFR - testons en pythonPyConFR - testons en python
PyConFR - testons en pythongburet
 

Similaire à PPT Python.pptx (20)

Tp python
Tp pythonTp python
Tp python
 
Python chapitre 3.pdf
Python chapitre 3.pdfPython chapitre 3.pdf
Python chapitre 3.pdf
 
FormationPython2019.pptx
FormationPython2019.pptxFormationPython2019.pptx
FormationPython2019.pptx
 
Linux Administrateur
Linux AdministrateurLinux Administrateur
Linux Administrateur
 
Algorithmique_et_programmation_part2
Algorithmique_et_programmation_part2Algorithmique_et_programmation_part2
Algorithmique_et_programmation_part2
 
Langage de Programmation.pdf
Langage de Programmation.pdfLangage de Programmation.pdf
Langage de Programmation.pdf
 
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
 
Chap XIII : calcul scientifique avec python
Chap XIII : calcul scientifique avec pythonChap XIII : calcul scientifique avec python
Chap XIII : calcul scientifique avec python
 
Programmation-en-C-ESIITECH-2023-2024-bis.pptx
Programmation-en-C-ESIITECH-2023-2024-bis.pptxProgrammation-en-C-ESIITECH-2023-2024-bis.pptx
Programmation-en-C-ESIITECH-2023-2024-bis.pptx
 
Python For Data Science - French Course
Python For Data Science - French CoursePython For Data Science - French Course
Python For Data Science - French Course
 
Programmation-en-C-ESIITECH-2023-2024.pptx
Programmation-en-C-ESIITECH-2023-2024.pptxProgrammation-en-C-ESIITECH-2023-2024.pptx
Programmation-en-C-ESIITECH-2023-2024.pptx
 
Machine-learning-FR.pdf
Machine-learning-FR.pdfMachine-learning-FR.pdf
Machine-learning-FR.pdf
 
découverte du langage python dans tous ses aspects
découverte du langage python dans tous ses aspectsdécouverte du langage python dans tous ses aspects
découverte du langage python dans tous ses aspects
 
pythonxxzexexzxzexzexzexzxzexezxzexzxz.pdf
pythonxxzexexzxzexzexzexzxzexezxzexzxz.pdfpythonxxzexexzxzexzexzexzxzexezxzexzxz.pdf
pythonxxzexexzxzexzexzexzxzexezxzexzxz.pdf
 
Python chapitre 4.pdf
Python chapitre 4.pdfPython chapitre 4.pdf
Python chapitre 4.pdf
 
Monkey & Monkey Runner
Monkey & Monkey RunnerMonkey & Monkey Runner
Monkey & Monkey Runner
 
Langage C
Langage CLangage C
Langage C
 
PyConFR - testons en python
PyConFR - testons en pythonPyConFR - testons en python
PyConFR - testons en python
 
Fascicule tp programmation c
Fascicule tp programmation cFascicule tp programmation c
Fascicule tp programmation c
 

Dernier

La nouvelle femme . pptx Film français
La   nouvelle   femme  . pptx  Film françaisLa   nouvelle   femme  . pptx  Film français
La nouvelle femme . pptx Film françaisTxaruka
 
Cours Préparation à l’ISO 27001 version 2022.pdf
Cours Préparation à l’ISO 27001 version 2022.pdfCours Préparation à l’ISO 27001 version 2022.pdf
Cours Préparation à l’ISO 27001 version 2022.pdfssuserc72852
 
Boléro. pptx Film français réalisé par une femme.
Boléro.  pptx   Film   français   réalisé  par une  femme.Boléro.  pptx   Film   français   réalisé  par une  femme.
Boléro. pptx Film français réalisé par une femme.Txaruka
 
COURS SVT 3 EME ANNEE COLLEGE 2EME SEM.pdf
COURS SVT 3 EME ANNEE COLLEGE 2EME SEM.pdfCOURS SVT 3 EME ANNEE COLLEGE 2EME SEM.pdf
COURS SVT 3 EME ANNEE COLLEGE 2EME SEM.pdfabatanebureau
 
Cours ofppt du Trade-Marketing-Présentation.pdf
Cours ofppt du Trade-Marketing-Présentation.pdfCours ofppt du Trade-Marketing-Présentation.pdf
Cours ofppt du Trade-Marketing-Présentation.pdfachrafbrahimi1
 
Sidonie au Japon . pptx Un film français
Sidonie    au   Japon  .  pptx  Un film françaisSidonie    au   Japon  .  pptx  Un film français
Sidonie au Japon . pptx Un film françaisTxaruka
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...Nguyen Thanh Tu Collection
 
Bolero. pptx . Film de A nnne Fontaine
Bolero. pptx . Film   de  A nnne FontaineBolero. pptx . Film   de  A nnne Fontaine
Bolero. pptx . Film de A nnne FontaineTxaruka
 
Apolonia, Apolonia.pptx Film documentaire
Apolonia, Apolonia.pptx         Film documentaireApolonia, Apolonia.pptx         Film documentaire
Apolonia, Apolonia.pptx Film documentaireTxaruka
 
L'ÉVOLUTION DE L'ÉDUCATION AU BRÉSIL À TRAVERS L'HISTOIRE ET LES EXIGENCES DE...
L'ÉVOLUTION DE L'ÉDUCATION AU BRÉSIL À TRAVERS L'HISTOIRE ET LES EXIGENCES DE...L'ÉVOLUTION DE L'ÉDUCATION AU BRÉSIL À TRAVERS L'HISTOIRE ET LES EXIGENCES DE...
L'ÉVOLUTION DE L'ÉDUCATION AU BRÉSIL À TRAVERS L'HISTOIRE ET LES EXIGENCES DE...Faga1939
 
gestion des conflits dans les entreprises
gestion des  conflits dans les entreprisesgestion des  conflits dans les entreprises
gestion des conflits dans les entreprisesMajdaKtiri2
 
Computer Parts in French - Les parties de l'ordinateur.pptx
Computer Parts in French - Les parties de l'ordinateur.pptxComputer Parts in French - Les parties de l'ordinateur.pptx
Computer Parts in French - Les parties de l'ordinateur.pptxRayane619450
 

Dernier (13)

La nouvelle femme . pptx Film français
La   nouvelle   femme  . pptx  Film françaisLa   nouvelle   femme  . pptx  Film français
La nouvelle femme . pptx Film français
 
Cours Préparation à l’ISO 27001 version 2022.pdf
Cours Préparation à l’ISO 27001 version 2022.pdfCours Préparation à l’ISO 27001 version 2022.pdf
Cours Préparation à l’ISO 27001 version 2022.pdf
 
Boléro. pptx Film français réalisé par une femme.
Boléro.  pptx   Film   français   réalisé  par une  femme.Boléro.  pptx   Film   français   réalisé  par une  femme.
Boléro. pptx Film français réalisé par une femme.
 
COURS SVT 3 EME ANNEE COLLEGE 2EME SEM.pdf
COURS SVT 3 EME ANNEE COLLEGE 2EME SEM.pdfCOURS SVT 3 EME ANNEE COLLEGE 2EME SEM.pdf
COURS SVT 3 EME ANNEE COLLEGE 2EME SEM.pdf
 
Cours ofppt du Trade-Marketing-Présentation.pdf
Cours ofppt du Trade-Marketing-Présentation.pdfCours ofppt du Trade-Marketing-Présentation.pdf
Cours ofppt du Trade-Marketing-Présentation.pdf
 
Sidonie au Japon . pptx Un film français
Sidonie    au   Japon  .  pptx  Un film françaisSidonie    au   Japon  .  pptx  Un film français
Sidonie au Japon . pptx Un film français
 
Evaluación Alumnos de Ecole Victor Hugo
Evaluación Alumnos de Ecole  Victor HugoEvaluación Alumnos de Ecole  Victor Hugo
Evaluación Alumnos de Ecole Victor Hugo
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI DẠY BUỔI 2) - TIẾNG ANH 6, 7 GLOBAL SUCCESS (2...
 
Bolero. pptx . Film de A nnne Fontaine
Bolero. pptx . Film   de  A nnne FontaineBolero. pptx . Film   de  A nnne Fontaine
Bolero. pptx . Film de A nnne Fontaine
 
Apolonia, Apolonia.pptx Film documentaire
Apolonia, Apolonia.pptx         Film documentaireApolonia, Apolonia.pptx         Film documentaire
Apolonia, Apolonia.pptx Film documentaire
 
L'ÉVOLUTION DE L'ÉDUCATION AU BRÉSIL À TRAVERS L'HISTOIRE ET LES EXIGENCES DE...
L'ÉVOLUTION DE L'ÉDUCATION AU BRÉSIL À TRAVERS L'HISTOIRE ET LES EXIGENCES DE...L'ÉVOLUTION DE L'ÉDUCATION AU BRÉSIL À TRAVERS L'HISTOIRE ET LES EXIGENCES DE...
L'ÉVOLUTION DE L'ÉDUCATION AU BRÉSIL À TRAVERS L'HISTOIRE ET LES EXIGENCES DE...
 
gestion des conflits dans les entreprises
gestion des  conflits dans les entreprisesgestion des  conflits dans les entreprises
gestion des conflits dans les entreprises
 
Computer Parts in French - Les parties de l'ordinateur.pptx
Computer Parts in French - Les parties de l'ordinateur.pptxComputer Parts in French - Les parties de l'ordinateur.pptx
Computer Parts in French - Les parties de l'ordinateur.pptx
 

PPT Python.pptx