implement XOR gate in python by R4R Team

-XOR is a logical gate that give output False if all of the input is same.

Truth table of XOR gate-

A B A and B
False False False
False True True
True False True
True True False


program-

def XOR(x,y):
if x==y:
return False
else:
return True

print("AtBtA XOR B")
print("False Falset",XOR(0,0))
print("False Truet",XOR(0,1))
print("True Falset",XOR(1,0))
print("True Truet",XOR(1,1))


output-

A B A XOR B
False False False
False True True
True False True
True TrueFalse


-In this program, we create a function that are able to return the XOR value of the given input.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!