Write a python function to clamp a number within a user specified range


Topic: Write a python function to clamp a number within a user specified range

Solution

def clamp_number(num, a, b):
  return max(min(num, max(a, b)), min(a, b))



List all Python Programs