How Are These Two Parameters Related?


#1

What is the relation between the two parameters (h and n) in these two functions? Why does “one_good_turn” in the second function must have (n) parameter?

def one_good_turn(h):
return h + 1

def deserves_another(n):
return one_good_turn(n) + 2

Thank you!


FAQ: Learn Python: Functions - Calling Functions
#2

uhm… the one_good_turn you are referring to doesn’t have a n parameter, it has an n argument. one_good_turn(n) is a function call, not a function definition.

lets add another function call so we can see these functions in action:

def one_good_turn(h):
    return h + 1

def deserves_another(n):
    return one_good_turn(n) + 2

print deserves_another(3) # output: 6

we pass the parameter n of deserves_another as argument to one_good_turn function call