Coding Custom min() and max() Functions
First, you import
lt() from the
operator module. These functions are the functional equivalent of the
< respectively. For example, the expression seen on-screen is equivalent to the function call seen on-screen.
You’ll use these functions to provide the
operator argument to
min_max(). Just like
default as arguments and return the minimum and maximum values, respectively. To perform the computation, these functions call
min_max() with the required arguments and with the appropriate comparison
operator function. In
custom_min(), you use
lt() to find the smallest value in the input data. In
Become a Member to join the conversation.