First class function properties:
Examples illustrating first class functions in Python
1. Functions are objects: Python functions are first class objects. In the example below, we are assigning a function to a variable. This assignment does not call the function. It takes the function object referenced by shout and creates a second name pointing to it, yell.
2. Functions can be passed as arguments to other functions: Since functions are objects, we can pass them as arguments to other functions. Functions that can take other functions as arguments are also called higher-order functions. In the example below, we have created a greet function that takes a function as an argument.
HI, I AM CREATED BY A FUNCTION PASSED AS AN ARGUMENT. hi, i am created by a function passed as an argument.
3. Functions can return another function: Since functions are objects, we can return a function from another function. In the example below, the create_adder function returns the adder function.