Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.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_Boolean - Fatal编程技术网

Python 有人能解释一下为什么答案是;“不正确”;而不是什么都没有?

Python 有人能解释一下为什么答案是;“不正确”;而不是什么都没有?,python,boolean,Python,Boolean,问题:以下代码将显示什么?代码如下: print调用中的表达式是形式为if else的单行if(有点类似于C或Java中的三元运算符)。既然isCorrect是False,它会返回“不正确”为什么你认为它应该没什么?我投票结束这个问题,因为懒散已经失控了。 isCorrect = False print("Correct" if isCorrect else "Incorrect") Answers: A. Correct B. Incorrect C. nothing D. C

问题:以下代码将显示什么?代码如下:



print
调用中的表达式是形式为
if else
的单行
if
(有点类似于C或Java中的三元运算符)。既然
isCorrect
False
,它会返回
“不正确”

为什么你认为它应该没什么?我投票结束这个问题,因为懒散已经失控了。
isCorrect = False 
print("Correct" if isCorrect else "Incorrect")
Answers: 
 A. Correct
 B. Incorrect
 C. nothing
 D. Correct Incorrect