For*_*cel 0 python boolean boolean-algebra
我正在写这本书"艰难地学习python".在练习27(http://learnpythonthehardway.org/book/ex27.html)中,它以布尔代数开始.
所以我的问题是:为什么是not(True and False)真的?
我是如何理解的,它应该是一样的False and True.
您的解释是不正确的,请参阅De Morgan的法律 ; 特别是否定一个连词就是否定的分离.
not (True and False)(否定一个连词 == not(a and b))相当于False or True(一个否定的分离 == (not a) or (not b)); 注意切换and到or!
您还可以执行以下步骤:
not(True and False)
True and False- >Falsenot(False)- > True.