这里默认hi>lo
不使用任何条件语句
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)
如题,如果把默认hi>lo去掉,对于任意三个值中间大小的值,如何不用条件语句一步直接return???对于n个变量呢?
小猫过河
相关分类