Tenho tanta coisa para fazer que decidir sentar-me no sofá a lançar aviões de papel…
Estive a ler um manual de Python e criei algumas funções. Por exemplo a função fatorial. Aqui vai:
>>> def mul(x,y): return x*y ... >>> def fat(w): return reduce(mul, range(1,w+1)) ... >>> fat(3) 6 >>> fat(4) 24 >>> fat(5) 120 >>> fat(6) 720
Até parece fácil 🙂
Deixe um comentário