Created
March 20, 2013 02:17
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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