implement NAND gate in python by R4R Team

- NAND is a logical gate that give output True if any of the input is false.
-NAND is combination gate of AND and NOT gate.
-If we do the NOT of the AND gate then we get the NAND gate.

Truth table of NAND gate-

A B A NAND B
False False True
False True True
True False True
True True False


program-

def NAND(x,y):
if x==1 and y==1:
return False
else:
return True

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


output-

A B A NAND B
False FalseTrue
False True True
True False True
True True False


-In this program, we create a function NAND(x,y) which give two argument and return True if any of the argument is False.




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!