Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 比较三个数字?_Python_Comparison - Fatal编程技术网

Python 比较三个数字?

Python 比较三个数字?,python,comparison,Python,Comparison,我正在上编程入门课,不知什么原因,我对如何从这里开始有点困惑。基本上,提示是比较用户输入的三个数字,看看第一个数字是否在最后两个数字之间 def fun1(a,b,read,): if a < read and read > b: return print("Yes") elif b < read and read > a: return print("Yes") else: return print

我正在上编程入门课,不知什么原因,我对如何从这里开始有点困惑。基本上,提示是比较用户输入的三个数字,看看第一个数字是否在最后两个数字之间

def fun1(a,b,read,):
    if a < read and read > b:
        return print("Yes")
    elif b < read and read > a:
        return print("Yes")
    else:
        return print("No")

def main():
   read = input("mid: ")
   a = input("num1 ") 
   b = input("num2 ")
   fun1(read,a,b,)
   print("result:",fun1)
def fun1(a、b、read、):
如果ab:
返回打印(“是”)
elif ba:
返回打印(“是”)
其他:
返回打印(“否”)
def main():
读取=输入(“mid:”)
a=输入(“num1”)
b=输入(“num2”)
fun1(读,a,b,)
打印(“结果:”,fun1)
如你所见,我不知道如何在第一个函数中得到比较函数。非常感谢您的帮助

Python允许您:

因此,在您的代码中,它类似于:

if a < read < b:
    return print("Yes")
elif b < read < a:
    return print("Yes")
else:
    return print("No")

如果有很多!事后看来,我应该意识到这一点。我想我当时太脑残了,只能求助于这里。谢谢!
if a <= b <= c:
if a < read < b:
    return print("Yes")
elif b < read < a:
    return print("Yes")
else:
    return print("No")
if (a < read < b) or (b < read < a):
    return print("Yes")
else:
    return print("No")
if (a < read < b) or (b < read < a):
    print("Yes")
else:
    print("No")