Save function result into a variable : Function Return « Function « Python






Save function result into a variable

Save function result into a variable

def times(x, y):      # create and assign function
     return x * y      # body executed when called


x = times(3.14, 4)    # save the result object
print x

           
       








Related examples in the same category

1.Define function: return int value Define function: return int value
2.Return more than one parametersReturn more than one parameters
3.A Simple function definition: return a tuple.A Simple function definition: return a tuple.
4.Return three value Return three value