MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / nand_gate

Function nand_gate

boolean_algebra/nand_gate.py:18–30  ·  view source on GitHub ↗

Calculate NAND of the input values >>> nand_gate(0, 0) 1 >>> nand_gate(0, 1) 1 >>> nand_gate(1, 0) 1 >>> nand_gate(1, 1) 0

(input_1: int, input_2: int)

Source from the content-addressed store, hash-verified

16
17
18def nand_gate(input_1: int, input_2: int) -> int:
19 """
20 Calculate NAND of the input values
21 >>> nand_gate(0, 0)
22 1
23 >>> nand_gate(0, 1)
24 1
25 >>> nand_gate(1, 0)
26 1
27 >>> nand_gate(1, 1)
28 0
29 """
30 return int(not (input_1 and input_2))
31
32
33if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected