Advertisement
francescom

Untitled

Jun 11th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. #Scrivere una funzione ricorsiva che, data una lista di numeri interi (positivi o
  2. #negativi), restituisce come risultato il valore vero se la somma dei numeri contenuti nella lista e un
  3. #valori pari, falso altrimenti. Se la lista e vuota, la funzione restituisce il valore vero.
  4. def funzionericorsiva(list, z=0):
  5.   #@param list:list
  6.   #@param z: integer
  7.   #@return boolean
  8.   if len(list)==0 and z%2==0:
  9.     return true
  10.   if len(list)==0 and z%2==1:
  11.     return false
  12.   z=z+int(list[0])
  13.   return funzionericorsiva(list[1:], z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement