You are on page 1of 2

EXPERIMENT -10

Aim: WAP to implement XOR using Python.


Theory:
A Logic gate is an elementary building block of any digital circuits. It takes one or two inputs
and produces output based on those inputs. Outputs may be high (1) or low (0). Logic gates are
implemented using diodes or transistors. The XOR gate gives an output of 1 if either both inputs
are different, it gives 0 if they are same.

CODING:

def XOR (a, b):


if a != b:
return 1
else:
return 0
# Driver code
if __name__=='__main__':
print(XOR(5, 5))
print("------------------------------------------")
print(" | XOR Truth Table | Result |")
print(" A = False, B = False | A AND B =",XOR(False,False)," | ")
print(" A = False, B = True | A AND B =",XOR(False,True)," | ")
print(" A = True, B = False | A AND B =",XOR(True,False)," | ")
print(" A = True, B = True | A AND B =",XOR(True,True)," | ")
OUTPUT:

RESULT:
The program is successfully done and compiled in python.

You might also like