Created
September 22, 2016 18:16
-
-
Save medina/2dcb3a53edfb5f69947f44693ceeb771 to your computer and use it in GitHub Desktop.
Boolean Logic w/ Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator | |
print "\t".join([ "A", "B", "A and B", "A or B", "A xor B"]) | |
for a in [True, False]: | |
for b in [True, False]: | |
print "\t".join( | |
str(x) for x in [ | |
a, b, operator.iand(a,b), operator.ior(a,b), operator.ixor(a,b), | |
]) | |
# A B A and B A or B A xor B | |
# True True True True False | |
# True False False True True | |
# False True False True True | |
# False False False False False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment