need to return back to caller with return values, as we look at the example returns a value:
final age () :
et = input ( how old are you?: )
return et # et and then returns the value of your age
# '
print age () # print a video la funzione eta
#se eta non ha valore stampa None
Che succede?? print eta() stampa a video la funzione con la variabile di ritorno richiamata da return facciamo un altro esempio:
def eta ( x , y ) :
risu = x + y
return risu
print eta ( 2 , 4 )
This example is better understood by changing the parameters of the print age (2.4) function is called and prints to video the value of the variable would return ECJ risu the result of an operation mathematics. the interesting thing is that we can assign to a variable in the entire opearzione a function like this:
final age ( x, y ) :
risu = x + y
return risu
to = age (2 , 4) # to become the return value
print " twice the function and operation ' " to + to
All this is possible thanks to the return value. In print "function and the dual operation, '" a + a print to video the first string and then the sum of the return value for himself.
0 comments:
Post a Comment