+ 1
Help please! Can someone help me understand this code?
x = 5 def fun(x): x = x - (x-2) return x print(fun(fun(fun(x-1))))
3 Respostas
+ 3
Inner function( fun(x-1) )is called first which returns 2 . value 2 becomes argument for another inner function (fun(2)) and this is how it goes on ..
+ 3
You should start with the innermost function
fun(x-1) and put for x 5. That mesns fun(5-1) = fun(4). So from definition of the function:
x= 4 - (4 - 2) = 4 - 2 = 2
So this return 2.
When you put this 2 into next function fun you get:
fun(2) = 2 - (2 - 2) = 2 and so on, and so on.
For this reason the result is 2.
+ 2
What is pcep?