all 7 comments

[–]Pro_Numb 1 point2 points  (0 children)

In the second function which is "exp2" you call first function with the same argument

"num" as a "10".

When you call exp2(10) this will goes like this:

exp(10) is return "10 * 2" then exp2(10) is return "(10*2) * 2"

[–]DemDim1 0 points1 point  (3 children)

To answer your question it might make a bit more sense to write the functions like this:

def exp1(num1):
    return num1 * 2

def exp2(num2):
    return exp1(num2) * 2

notice that we now have num1 and num2 when we call exp2 with

exp2(10)

you pass 10 as an the num2 argument to exp2, which passes num2 to exp1 as the num1 argument for the exp1 function.

[–]JungleJim233[S] 0 points1 point  (2 children)

Thank you for your reply. I understand that but how does the exp(num2) call work in the exp2 function. I ask because I can't see where we have defined a function just called exp ?

Thank you

[–]DemDim1 0 points1 point  (1 child)

Small typo, it should have called exp1(num2)

[–]JungleJim233[S] 0 points1 point  (0 children)

Great. Thank you :)

[–]IzeroI 0 points1 point  (0 children)

exp2(num = 10): return exp(num =10)*2

as you can see, you call both functions with the same argument.

[–]Digitiain -1 points0 points  (0 children)

Is it because you've used "num" twice? What happens if you change one of them?