
AND Gate in Python
如果两个输入均为 1,则 AND 门给出输出 1,否则给出 0。

def AND (a, b):
if a == 1 and b == 1:
return True
else:
return False
NAND Gate in Python
如果两个输入均为 1,则 NAND gate (negated AND)给出 0 的输出,否则给出 1。

def NAND (a, b):
if a == 1 and b == 1:
return False
else:
return