I am having difficulty in understanding what it means by returning a function, and what exactly are practical usages of returning functions. Also, for my knowledge, how the below codes work in background.
def f1():
    x = 99
    def f2():
        print(x)
    return f2
f1()
Output:
<function __main__.f1.<locals>.f2()>
now when I use, f1()(), it returns 99. I basically want to understand what happens in background.
def f1():
    x = 99
    def f2():
        print(x)
    return f2
f1()()
Returns 99
