def surface(w,h):
print "calculating the surface by multiplying two input values"
return w*h
# call the function
print surface(4,5)
Multiple return values
In Python, a function can return multiple values in one call.def multireturn(x):
return x, x+2, x+4
print multireturn(5)
The return value is actually an array:
def multireturn(x):
return x, x+2, x+4
y=multireturn(20)
print y[0]
print y[1]
print y[2]
default parameters
Specify a default value:def foo(a,b=5):
bar