min by max python code example
Example 1: python maths max value capped at x
def clamp(n, minn, maxn):
return max(min(maxn, n), minn)
Example 2: python get min from array
>>> arr = [1, 3.14159, 1e100, -2.71828]
>>> min(arr)
-2.71828
def clamp(n, minn, maxn):
return max(min(maxn, n), minn)
>>> arr = [1, 3.14159, 1e100, -2.71828]
>>> min(arr)
-2.71828