compose(f, g) that returns a new function h such that h(x) == f(g(x)) for any x. This is standard function composition: apply g first, then f to its result.def add_one(x): return x + 1 def square(x): return x * x h = compose(square, add_one) h(3)
16
g=add_one is applied first: 3+1=4, then f=square: 4*4=16.
Define an inner function that takes x, calls g(x) first, then passes that result into f.
Return the inner function without calling it.