The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

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?

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?

0
Votes
1
Answer

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 .
 

1 Answer

365 Team
0
Votes

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