我想弄清楚我的代码为什么不能工作。为什么我的一些逻辑门,比如OR,没有给我正确的输出?以OR门为例。当我运行代码并传入1作为A和B的值时,输出仍然是False。我已经试过调整它,但它仍然提供False作为输出。
下面是我迄今为止所做的一个例子:aInput = int(input('Enter value for A: '))
bInput = int(input('Enter value for B: '))
#AND Gate
if aInput == 1 and bInput == 1:
ANDGate = "True"
ANDGateNum = 1
else:
ANDGate = "False"
ANDGateNum = 0
print('AND Gate output is', ANDGate, 'or', ANDGateNum)
#NAND Gate
if aInput == 1 and bInput == 1:
NANDGate = "False"
NANDGateNum = 0
else:
NANDGate = "True"
NANDGateNum = 1
print('NAND Gate output is', NANDGate, 'or', NANDGateNum)
#OR Gate
if aInput == 1 and bIn