Define a function that adds 5 to the parameter. Then, define another function that will multiply the newly obtained number by 3. Verify your code was correct by calling the second function with an argument of 5. Was your output equal to 30?
def addition_of_five(inner_fun):
return inner_fun + 5 def multiplication_of_three(inner_fun):
return addition_of_five(inner_fun) * 3 addition_of_five(5), multiplication_of_three(5) output: (10, 20) Why it is showing 20 for second function call? I think it should be 30 .
return inner_fun + 5 def multiplication_of_three(inner_fun):
return addition_of_five(inner_fun) * 3 addition_of_five(5), multiplication_of_three(5) output: (10, 20) Why it is showing 20 for second function call? I think it should be 30 .
2 answers ( 0 marked as helpful)
Hi Raj,
when I run the code, I get an output of (10, 30), so there seems to be an issue somewhere else in the code. I'd suggest you restart your kernel and run only this line, to see if that changes the result.
Best,
Eli
def fun1(n):
v = 5 + n
num = fun2(v)
return num
def fun2(a_number):
a_number = a_number * 3
return a_number
print(fun1(5))