title: Python Logic Code: AND, NAND, OR, NOR, XOR, XNOR, & NOT simulation
body: <p>I'm trying to figure out why my code isn't working. Why are some of my logic gates, like <code>OR</code>, not giving me the correct output? Take the <code>OR</code> gate for example. When I run the code and pass in <code>1</code> as the value for <code>A</code> and <code>B</code>, the output is still <code>False</code>. I have tried tweaking it and it still gives me <code>False</code> as the output.</p>
  
  <p>Below is an example of what I did so far:</p>
  
  <pre><code>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 bInput == 1:
      ORGate = "True"
      ORGateNum = 1
  if aInput == 1 and bInput == 0:
      ORGate = "True"
      ORGateNum = 1
  if aInput == 0 and bInput == 1:
      ORGate = "True"
      ORGateNum = 1
  else:
      ORGate = "False"
      ORGateNum = 0
  
  print('OR Gate output is', ORGate, 'or', ORGateNum)
  
  #NOR Gate
  if aInput == 1 and bInput == 1:
      NORGate = "False"
      NORGateNum = 0
  if aInput == 1 and bInput == 0:
      NORGate = "False"
      NORGateNum = 0
  if aInput == 0 and bInput == 1:
      NORGate = "False"
      NORGateNum = 0
  else:
      NORGate = "True"
      NORGateNum = 1
  
  print('NOR Gate output is', NORGate, 'or', NORGateNum)
  
  #XNOR Gate
  if aInput == 1 and bInput == 1:
      XNORGate = "True"
      XNORGateNum = 1
  if aInput == 1 and bInput == 0:
      XNORGate = "False"
      XNORGateNum = 0
  if aInput == 0 and bInput == 1:
      XNORGate = "False"
      XNORGateNum = 0
  else:
      XNORGate = "True"
      XNORGateNum = 1
  
  print('XNOR Gate output is', XNORGate, 'or', XNORGateNum)
  
  #XOR Gate
  if aInput == 1 and bInput == 1:
      XORGate = "False"
      XORGateNum = 0
  if aInput == 1 and bInput == 0:
      XORGate = "True"
      XORGateNum = 1
  if aInput == 0 and bInput == 1:
      XORGate = "True"
      XORGateNum = 1
  else:
      XORGate = "False"
      XORGateNum = 0
  
  print('XOR Gate output is', XORGate, 'or', XORGateNum)
  
  #NOT Gate
  if aInput == 1: 
      NOTGate = "False"
      NOTGateNum = 0
  
  else:
      NOTGate = "True"
      NOTGateNum = 1
  
  print('NOT Gate output is', NOTGate, 'or', NOTGateNum)
  </code></pre>
  
  <p>I also tried replacing the <code>and</code> in between <code>aInput</code> and <code>bInput</code> with an <code>or</code> which seems to work, but a little tough to repeat usage with the <code>XOR</code> and <code>XNOR</code> gates:</p>
  
  <pre><code>#OR Gate
  if aInput == 1 or bInput == 1:
      ORGate = "True"
      ORGateNum = 1
  else:
      ORGate = "False"
      ORGateNum = 0
  
  print('OR Gate output is', ORGate, 'or', ORGateNum)
  
  #NOR Gate
  if aInput == 1 or bInput == 1:
      NORGate = "False"
      NORGateNum = 0
  else:
      NORGate = "True"
      NORGateNum = 1
  
  print('NOR Gate output is', NORGate, 'or', NORGateNum)
  </code></pre>