The Question : 358 people think this question is useful Does Python support short-circuiting in boolean expressions? The Question Comments : Closely related: Strange use of “and” / “or” operator The Answer 1 333 people think this answer is useful Yep, both and and or operators short-circuit — see the docs. The Answer 2 209

The Question : 585 people think this question is useful An interviewer recently asked me this question: given three boolean variables, a, b, and c, return true if at least two out of the three are true. My solution follows: He said that this can be improved further, but how? The Question Comments : Inline

我正在尝试创建一个函数，将多个变量与一个整数进行比较，并输出一个由三个字母组成的字符串。我想知道是否有办法将其翻译成Python。所以说： x = 0 y = 1 z = 3 mylist = if x or y or z == 0 : mylist.append("c") if x or y or z == 1 : mylist.append("d") if x or y or z == 2 : mylist.append("e") if x or y or z == 3 : mylist.append("f") 这将返回一个列表 ["c",