First page Back Continue Last page Overview Graphics

Functions: Example

def foobar(x, y):

""" This is a functions which adds 42 to the

sum of the arguments x and y """

return x + y + 42

a = 3

print(a+3, 5)

Output

53

def foobar(x=1, y=0):

""" This is a functions which adds 42 to the

sum of the arguments x and y """

return x + y + 42

a = 3

print(foobar(a+3, 5))

print(foobar(a+3))

print(foobar())

Output

53

48

43