【发布时间】:2015-11-09 10:16:05
【问题描述】:
我似乎无法掌握 Bootlean 运算符。我正在使用 Code Academy 的示例。一开始我读错了,我把True or not False and False而不是True or False。
谁能给我解释得更清楚一点,这样我可以得到更多的理解。
Assign True or False as appropriate for bool_one through bool_five.
Set bool_one equal to the result of False or not True and True
Set bool_two equal to the result of False and not True or True
Set bool_three equal to the result of True and not (False or False)
Set bool_four equal to the result of not not True or False and not True
Set bool_five equal to the result of False or not (True and True)
【问题讨论】:
-
首先应用 Python 的运算符优先级规则添加括号,以便操作的分组在视觉上清晰。 (这里的相关规则是“and”的优先级高于“or”,即“a and b or c”等价于“(a and b) or c”,而不是“a and (b or c)”。 ) 完成此操作后,计算出括号表达式的计算结果以及更大的表达式的计算结果。
标签: python boolean boolean-logic