code: def clamp(n, lower, upper):
      
      if lower > upper:
          lower, upper = upper, lower
      return max(min(upper, n), lower)
docs: Restricts the given number to a lower and upper bound (inclusive)
  
      :param n:     input number
      :param lower: lower bound (inclusive)
      :param upper: upper bound (inclusive)
      :return:      clamped number