+ 2

Explain the question

def f(x): return(2*x+1) def g(x): return(x-1) print(g(f(2)-f(g(2)))

18th Jan 2021, 2:34 PM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar
2 Respuestas
+ 3
This is a nested function which performs a specific equation with given parameters. Equation of "g" : ---> x - 1 Equation of "f" : ---> (2 * x) + 1 Then we will just solve those each of those functions until we got only 2 numbers and evaluate. - - - - - - - - - - - - First, let's focus on the main equation which is: g (f(2)) - f (g(2)) - - - - - - - - - - - - # First solve the first term: g(f(2)) f(2) = 2 * 2 + 1 f(2) = 5 ---> g(f(2)) --->g(5) 👇 g(5) = 5 - 1 g(5) = 4 So now the first term is 4 - - - - - - - - - - - - # Next is the second term: f(g(2)) g(2) = 2 - 1 g(2) = 1 ---> f(g(2)) ---> f(1) 👇 f(1) = 2 * 1 + 1 f(1) = 3 So now the second term is 3 - - - - - - - - Therefore: g(f(2)) ---> 4 f(g(2)) ---> 3 4 - 3 >> 1 If this is still not clear, then please feel free to ask. Thanks!
18th Jan 2021, 2:42 PM
noteve
noteve - avatar
+ 2
《 Nicko12 》 thank you so much
19th Jan 2021, 1:10 PM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar