Ressources :
python3 -m venv .env source .env/bin/activate
urls=(1,2) print (type(urls)) print (str(len(urls) + 1) + " requests sent")
age = "3" age = int(age)
liste = [1,2,3,4] liste.append(5) liste.insert(2,2.5) liste.remove(4) print(liste)
dic = {} dic['m1'] = "p1" dic['m2'] = "p2" print(dic)
{'m1': 'p1', 'm2': 'p2'}
age = 114 if age > 18 and age <=90 : print("majeur") elif age > 90: print("Centenaire") else: print("Mineur")
for index in [1,2,3,4,5]: print index
for index in ranger(0,4) print index
for index in "hello": print index
h e l l o
for cle, valeur in dic.items(): print("{} -> {}".format(cle,valeur))
t=0 while t <= 256: t+=1 print t
while 1: lettre = input("Tapez q pour quitter") if lettre == "q" print("Quit") break lettre = "" while lettre = "q" lettre = input("Tapez q pour quitter") print("Quit")
of =open("test.txt", "rb") # "rb" => mode lecture (r) binaire (b) octets =of.read()
annee = input("Annee de naissance :") print(annee)
#!/usr/bin/env python # -*- coding: ascii -*- import sys def send_message(message): sys.stdout.write('{0}\r\n'.format(message)) sys.stdout.flush() def read_message(): return sys.stdin.readline() chaine = read_message() send_message(chaine)
class ClasseVoiture: marque = "Lambo" attribue = "valeur" def __init__(self, parametre): param = parametre instance_voiture01 = ClasseVoiture() print(instance_voiture01.marque) print(instance_voiture01("init"))
def fonc(a=1, b=2): print("a =", a, "b =", b) fonc() >>> a = 1 b = 2 fonc('number',4) >>> a = number b = 4 age = 0 def demander_age(): global age return age+1 print (demander_age())
p = lambda variable: print("une fonction qui est : " + variable) p("courte")
age=12 try: print ("block d'instruction à essayer ") age_prochain = int(age) +1 except: print ("erreur" + "block a executer en cas d'erreur") else: print ("block instruction a executer si l'essait est bon") print ("l'age prochain est " str(age_prochain))