# ex12002_return.py ''' Valeur retournée par une fonction ''' def maFunc(x): #============= '''Un exemple de fonction qui retourne une valeur.''' y = x**2 + 1 return y print("----- Exercice 12.02a -----") y1 = maFunc(2) print("f(2) =", y1) y2= maFunc(2.5) print("f(2.5) =", y2) print("f(3) =", maFunc(3)) def SuiteJolie(strS): #==================== # ... À commenter ... strRep = "" cLast = " " cpt = 1 for cc in strS: if (cLast == " "): # Cas du premier caractère cLast = cc elif (cc == cLast): cpt += 1 elif (cc != " "): # On change de caractère strRep += str(cpt) + cLast cLast = cc cpt = 1 strRep += str(cpt) + cLast return strRep print("----- Exercice 12.02b -----") strS = "1" ; print(strS) for k in range(10): strS = SuiteJolie(strS); print(strS)