6 February 2012 Exemple d’affichage des objets avec ‘print’ Python Basic x = 10 y="Bienvenu" a=" allo" z=3.14 #Affichage d'un objet simple print x #Affichage de plusieursx = 10 y="Bienvenu" a=" allo" z=3.14 #Affichage d'un objet simple print x #Affichage de plusieurs python
6 February 2012 Gestion de plusieurs Exceptions Python Basic def division(x, y): try: return(x/y) except ZeroDivisionError: # Prem def division(x, y): try: return(x/y) except ZeroDivisionError: # Prem python
6 February 2012 Obtenir le type d’un objet avec la méthode ‘type()’ Python Basic x = 10 y="Bienvenu" z=3.14 a=["allo",12,3.14] print type(x) #Afficher le type de 'x' printx = 10 y="Bienvenu" z=3.14 a=["allo",12,3.14] print type(x) #Afficher le type de 'x' print python
6 February 2012 Afficher la liste des mots clés python Python Basic import keyword for mot in keyword.kwlist: print "#"+mot # ce module affiche ça #and #as #assimport keyword for mot in keyword.kwlist: print "#"+mot # ce module affiche ça #and #as #ass python
6 February 2012 Lire l’entrée clavier avec la méthode ‘raw_input()’ Python Basic import math as operation while 1: val1=raw_input("Tapez Opérande #1(-1 pour quitter): ")import math as operation while 1: val1=raw_input("Tapez Opérande #1(-1 pour quitter): ") python
6 February 2012 python: Supprimer une variable avec le mot clé del”” Python Basic # initialiser deux variable a , b= "Lundi", "Janvier" #Afficher les valeurs des deux variab# initialiser deux variable a , b= "Lundi", "Janvier" #Afficher les valeurs des deux variab python
6 February 2012 python: Exemple de conversion des nombres Python Basic #Définition d'une variable x x="10" #Convertir et afficher les résultats print int(x) print lo#Définition d'une variable x x="10" #Convertir et afficher les résultats print int(x) print lo python
6 February 2012 Exemple des commentaires en Python Python Basic # Ceci est un # Commentaire # Python. import os #Commentaire print " Symbole # pour commen# Ceci est un # Commentaire # Python. import os #Commentaire print " Symbole # pour commen python
6 February 2012 Fonction: Accède à une variable globale avec le mot clé ‘global’ Python Basic def fonc_compter( ): # Incrémenter la variable compteur '_compteur' global _compteurdef fonc_compter( ): # Incrémenter la variable compteur '_compteur' global _compteur python
6 February 2012 Concaténation ou assemblage des chaînes de caractères en python Python Basic import sys mot1="J'aime" mot2="Programmer" mot3="avec python" listMots = ["Apprendre", "à", "pro import sys mot1="J'aime" mot2="Programmer" mot3="avec python" listMots = ["Apprendre", "à", "pro python