2019-04-12
阅读量:
545
python中的add函数
如果两个输入都是1,AND门给出1的输出,否则给出0。
# Python3 progarm to illustrate
# working of AND gate
def AND (a, b):
if a == 1 and b == 1:
return True
else:
return False
# Driver code
if __name__=='__main__':
print(AND(1, 1))
print("+---------------+----------------+")
print(" | AND Truth Table | Result |")
print(" A = False, B = False | A AND B =",AND(False,False)," | ")
print(" A = False, B = True | A AND B =",AND(False,True)," | ")
print(" A = True, B = False | A AND B =",AND(True,False)," | ")
print(" A = True, B = True | A AND B =",AND(True,True)," | ")
输出:
True
+---------------+----------------
| AND Truth Table | Result |
A = False, B = False | A AND B = False |
A = False, B = True | A AND B = False |
A = True, B = False | A AND B = False |
A = True, B = True | A AND B = True |






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论