formation python

33
Formation python

Upload: sayf-eddine-hammemi

Post on 05-Jul-2015

292 views

Category:

Technology


8 download

TRANSCRIPT

Page 1: Formation python

Formation python

Page 2: Formation python

Python ? C’est quoi ?

Python est une language de programmation interprétée de haut niveau

comme ( java , perl , Ruby etc. .. ) basée sur la language C

Page 3: Formation python

Programmes et sites web qui utilisent

python :

Page 4: Formation python
Page 5: Formation python

Avantages de

programmation

en python :

Page 6: Formation python

Avantages de

programmation

en python :

• MOINS

D’ERREURS

SYNTAXIQUES :

Pas de semi-colon ,

Indentation obligatoire,

Pas d’accolades pour les block d’instructions

Page 7: Formation python

LANGUAGE

INTERPRÉTÉE :

Avantages de

programmation

en python :

Test du quelque lignes du code sans besoin

D’écrire un programme complet :

Page 8: Formation python

IMPLÉMENTATION

DES AUTRES

LANGUAGES

Avantages de

programmation

en python :

Jython (java), Cython (C/C++) ,

ironPyton (C#) sont des

Implémentation des autres languages

Dans la language python

Page 9: Formation python

De quoi as-t-on besoin pour coder

en python - sous linux et sous

Windows :

Page 10: Formation python

Sous Windows :

• Visitez

www.python.org/download/releases/

• Choisir la version qui vous convient

• Téléchargez le fichier exécutable

• Installez et commencez à coder !

Page 11: Formation python
Page 12: Formation python
Page 13: Formation python
Page 14: Formation python

Sous linux :

Python est déjà installé sur les différentes distributions du linux

Pour installer une autre version :

• Par la commande :

sudo add-apt-repository ppa:fkrull/deadsnakes

sudo apt-get update

sudo apt-get install python2.7

Page 15: Formation python

Compilation du

code :

Page 16: Formation python

Syntaxe du Python :

Page 17: Formation python

Déclaration des

variables

Page 18: Formation python

Déclaration des

variables

Page 19: Formation python

Déclaration des

variables

En python on ne mentionne pas

les types des variables,

Page 20: Formation python

les conditions :if (condition):

instruction 1

instruction n

#retour a la ligne sans indentation

Condition simple :

Page 21: Formation python

les conditions :

if (condition):

instruction 1

instruction n

elif:

instruction 1

instruction n

#retour a la ligne sans indentation

Condition composée :

Page 22: Formation python

les conditions :

if (condition 1):

instruction 1

instruction n

else if (condition 2):

instruction 1

instruction n

else:

instruction 1

instruction n

#retour a la ligne sans indentation

Conditions imbriquée :

Page 23: Formation python

les boucles :

for i in range(9):

print i

#retour à la ligne

For i in (1,3,5,7,9):

instructions

#retour à la ligne

For i in ‘’chaine de caractere’’:

instructions

#retour à la ligne

Boucle pour :

Page 24: Formation python

les boucles :While (condition):

instruction 1

….

instruction n

#retour à la ligne

Tant que :

Page 25: Formation python

les commentaires :

#ceci est un commentaire sur un seul ligneSur un seul ligne :

Page 26: Formation python

les commentaires :

‘’’ ceci est

Commentaire

Sur des lignes multiples’’’

Sur des lignes multiples :

Page 27: Formation python

les entrées sorties :Variable=input(‘’ entrer le variable’’)

#pour les chaine de caractère il est

préférable

Nom=raw_input(‘’entrer votre nom’’)

Entrée :

Page 28: Formation python

les entrées sorties :a=‘’chaine’’

#pour python 2.x

print a

#pour python 3.x

print(a)

sortie :

Page 29: Formation python

les entrées sorties :

a,b,c=‘chaine’,’chaine2’,’chaine3’

Print ‘a=%s b=%s c=%s’ %(a,b,c)Sortie formatée :

Page 30: Formation python

Hello name ! #include<stdio.h>

main(){

Char name[50];

scanf(‘’ entrer votre nom : %s \n’’,name);

printf(‘’hello %s \n’’,name);

}

En C :

Page 31: Formation python

Hello name !

package proj0;

Import java.util.Scanner

public class Proj0

{

public static void main(String[] args)

{

char name;

sc= new Scanner(system.in);

System.out.println(‘’entrer votre nom’’);

name=sc.nextLine();

System.out.println("Hello" + name);

}

}

En Java :

Page 32: Formation python

Hello name !

name=raw_input(‘’entrer votre nom’’)

print ‘’Hello %s‘’ %nameEn python :

Page 33: Formation python

Liens utiles

WWW.PYTHON.ORG

DOCS.PYTHON.ORG

WWW.LEARNPYTHON.ORG

LEARNPYTHONTHEHARDWAY.ORG

WWW.CODECADEMY.COM/TRACKS/

PYTHON