Python: Logic Gates Damian Gordon AND gate
Description: Python: Logic Gates Damian Gordon AND gate simulation A AND B: A B OUT AND gate simulation def AND(a,b): if a True and b True : return True else: return False END AND. NAND gate simulation Not of AND: A B OUT NAND gate simulation
Related Topics
Download Presentation
"Python: Logic Gates Damian Gordon AND gate" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Presentation Transcript
slide1. Python: Logic Gates Damian Gordon<br>
slide2. AND gate simulation A AND B: A B OUT<br>
slide3. AND gate simulation def AND(a,b):
if a == True and b == True :
return True
else:
return False
# END AND.<br>
slide4. NAND gate simulation Not of AND: A B OUT<br>
slide5. NAND gate simulation def NAND(a,b):
if a == True and b == True:
return False
else:
return True
# END NAND.<br>
slide6. OR gate simulation A OR B: A B OUT<br>
slide7. OR gate simulation def OR(a,b):
if a == True:
return True
elif b == True:
return True
else:
return False
# END OR.<br>
slide8. XOR gate simulation A XOR B: A B OUT<br>
slide9. XOR gate simulation def XOR(a,b) :
if a != b:
return True
else:
return False
# END XOR.<br>
slide10. TAUTology gate simulation Always TRUE: T A B TRUE<br>
slide11. TAUTology gate simulation def TAUT(a,b):
return True
# END TAUT.<br>
slide12. Printing Truth Tables<br>
slide13. NAND Truth Table print("+----------------------+--------------------+")
print("| NAND Truth Table | Result |")
print("+----------------------+--------------------+")
print ("| A = False, B = False | A NAND B = ", NAND(False,False)," |")
print ("| A = False, B = True | A NAND B = ", NAND(False,True)," |")
print ("| A = True, B = False | A NAND B = ", NAND(True,False)," |")
print ("| A = True, B = True | A NAND B = ", NAND(True,True),"|")
print("+----------------------+--------------------+")<br>
slide14. NAND Truth Table +----------------------+--------------------+
| NAND Truth Table | Result |
+----------------------+--------------------+
| A = False, B = False | A NAND B = True |
| A = False, B = True | A NAND B = True |
| A = True, B = False | A NAND B = True |
| A = True, B = True | A NAND B = False |
+----------------------+--------------------+<br>
slide15. XOR Truth Table print("+----------------------+-------------------+")
print("| XOR Truth Table | Result |")
print("+----------------------+-------------------+")
print ("| A = False, B = False | A XOR B = ", XOR(False,False),"|")
print ("| A = False, B = True | A XOR B = ", XOR(False,True)," |")
print ("| A = True, B = False | A XOR B = ", XOR(True,False)," |")
print ("| A = True, B = True | A XOR B = ", XOR(True,True),"|")<br>
slide16. XOR Truth Table +----------------------+-------------------+
| XOR Truth Table | Result |
+----------------------+-------------------+
| A = False, B = False | A XOR B = False |
| A = False, B = True | A XOR B = True |
| A = True, B = False | A XOR B = True |
| A = True, B = True | A XOR B = False |
+----------------------+-------------------+<br>
slide17. etc.<br>
slide2. AND gate simulation A AND B: A B OUT<br>
slide3. AND gate simulation def AND(a,b):
if a == True and b == True :
return True
else:
return False
# END AND.<br>
slide4. NAND gate simulation Not of AND: A B OUT<br>
slide5. NAND gate simulation def NAND(a,b):
if a == True and b == True:
return False
else:
return True
# END NAND.<br>
slide6. OR gate simulation A OR B: A B OUT<br>
slide7. OR gate simulation def OR(a,b):
if a == True:
return True
elif b == True:
return True
else:
return False
# END OR.<br>
slide8. XOR gate simulation A XOR B: A B OUT<br>
slide9. XOR gate simulation def XOR(a,b) :
if a != b:
return True
else:
return False
# END XOR.<br>
slide10. TAUTology gate simulation Always TRUE: T A B TRUE<br>
slide11. TAUTology gate simulation def TAUT(a,b):
return True
# END TAUT.<br>
slide12. Printing Truth Tables<br>
slide13. NAND Truth Table print("+----------------------+--------------------+")
print("| NAND Truth Table | Result |")
print("+----------------------+--------------------+")
print ("| A = False, B = False | A NAND B = ", NAND(False,False)," |")
print ("| A = False, B = True | A NAND B = ", NAND(False,True)," |")
print ("| A = True, B = False | A NAND B = ", NAND(True,False)," |")
print ("| A = True, B = True | A NAND B = ", NAND(True,True),"|")
print("+----------------------+--------------------+")<br>
slide14. NAND Truth Table +----------------------+--------------------+
| NAND Truth Table | Result |
+----------------------+--------------------+
| A = False, B = False | A NAND B = True |
| A = False, B = True | A NAND B = True |
| A = True, B = False | A NAND B = True |
| A = True, B = True | A NAND B = False |
+----------------------+--------------------+<br>
slide15. XOR Truth Table print("+----------------------+-------------------+")
print("| XOR Truth Table | Result |")
print("+----------------------+-------------------+")
print ("| A = False, B = False | A XOR B = ", XOR(False,False),"|")
print ("| A = False, B = True | A XOR B = ", XOR(False,True)," |")
print ("| A = True, B = False | A XOR B = ", XOR(True,False)," |")
print ("| A = True, B = True | A XOR B = ", XOR(True,True),"|")<br>
slide16. XOR Truth Table +----------------------+-------------------+
| XOR Truth Table | Result |
+----------------------+-------------------+
| A = False, B = False | A XOR B = False |
| A = False, B = True | A XOR B = True |
| A = True, B = False | A XOR B = True |
| A = True, B = True | A XOR B = False |
+----------------------+-------------------+<br>
slide17. etc.<br>