def hornercompleto (a,x): b=0; v=[] for ak in a: b=b*x+ak; v.append(b) return v def taylor (a,x): v=a # Corretto, ma cfr. terza colonna. w=[] while v: v=hornercompleto(v,x) w.append(v.pop()) return w a=(3,5,6,8,7) print taylor(a,2) # [135, 188, 108, 29, 3] --------------------------------------- def f(x,y): return x+2*y print f(y=2,x=7) # 11 --------------------------------------- def f(x,y,z): return x+2*y+3*z print f(2,z=4,y=1) # 16 --------------------------------------- def f(x,y,z=4): return x+2*y+3*z print f(2,1) # 16 print f(2,1,5) # 19 print f(2,z=5,y=1) # 19 def tel (nome,numero,prefisso='0532'): return [nome,prefisso+'-'+numero] print tel('Rossi','974002') # ['Rossi', '0532-974002'] --------------------------------------- def f(x,v=[]): v.append(x); print v f(7) # [7] f(8) # [7, 8] --------------------------------------- def f(x,y=3): print x+y; y+=1 f(1) # 4 f(1) # 4 - perche' y non e' mutabile. --------------------------------------- def f(x,a): b=a; b.append(x); return b a=[1,2] f(4,a) print a # [1, 2, 4] f(5,a) print a # [1, 2, 4, 5] --------------------------------------- def f(x): print x+3 f(7) # 10 def f(x,y): print x+y f(3,9) # 12