Skip to content

Instantly share code, notes, and snippets.

@PatchRowcester
Created March 20, 2013 02:17
Show Gist options
  • Save PatchRowcester/5201802 to your computer and use it in GitHub Desktop.
Save PatchRowcester/5201802 to your computer and use it in GitHub Desktop.
Takes in three numbers and returns a value based on the value of x. Returns: - lo, when x < lo - hi, when x > hi - x, otherwise
def clip(lo, x, hi):
'''
Takes in three numbers and returns a value based on the value of x.
Returns:
- lo, when x < lo
- hi, when x > hi
- x, otherwise
'''
# Your code here
return min(max(x,lo),hi)
z = clip(3,2,1)
print(str(z))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment