问题描述
我们可以通过简单的代码显示AND,OR的条件:
def funAnd():
如果condition1 和条件2:
返回True
#######
0 | 0 - > 0
0 | 1 - > 0
1 | 0 - > 0
1 | 1 - > 1
def funOr():
如果条件1 或条件2:
返回True
#######
0 | 0 - > 0
0 | 1 - > 1
1 | 0 - > 1
1 | 1 - > 1
######################################## br />
如何为XOR,NAND,NOR,XNOR逻辑生成条件测试。
########## XOR
0 | 0 - > 0
0 | 1 - > 1
1 | 0 - > 1
1 | 1 - > 1
########## NAND
0 | 0 - > 1
0 | 1 - > 1
1 | 0 - > 1
1 | 1 - > 0
########## NOR
0 | 0 - > 1
0 | 1 - > 0
1 | 0 - > 0
1 | 1 - > 0
########## XNOR
0 | 0 - > 1
0 | 1 - > 1
1 | 0 - > 1
1 | 1 - > 0
我们如何测试这些逻辑?
We can show conditions for AND, OR by simple codes:
def funAnd():
if condition1 and condition2:
return True
#######
0 | 0 -> 0
0 | 1 -> 0
1 | 0 -> 0
1 | 1 -> 1
def funOr():
if condition1 or condition2:
return True
#######
0 | 0 -> 0
0 | 1 -> 1
1 | 0 -> 1
1 | 1 -> 1
#######################################
what about generating conditional tests for XOR, NAND, NOR, XNOR logics.
########## XOR
0 | 0 -> 0
0 | 1 -> 1
1 | 0 -> 1
1 | 1 -> 1
########## NAND
0 | 0 -> 1
0 | 1 -> 1
1 | 0 -> 1
1 | 1 -> 0
########## NOR
0 | 0 -> 1
0 | 1 -> 0
1 | 0 -> 0
1 | 1 -> 0
########## XNOR
0 | 0 -> 1
0 | 1 -> 1
1 | 0 -> 1
1 | 1 -> 0
How can we test for these logic?
推荐答案
这篇关于为XOR,NAND,NOR,XNOR逻辑编写代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!