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

Function xor_gate

boolean_algebra/xor_gate.py:18–31  ·  view source on GitHub ↗

calculate xor of the input values >>> xor_gate(0, 0) 0 >>> xor_gate(0, 1) 1 >>> xor_gate(1, 0) 1 >>> xor_gate(1, 1) 0

(input_1: int, input_2: int)

Source from the content-addressed store, hash-verified

16
17
18def xor_gate(input_1: int, input_2: int) -> int:
19 """
20 calculate xor of the input values
21
22 >>> xor_gate(0, 0)
23 0
24 >>> xor_gate(0, 1)
25 1
26 >>> xor_gate(1, 0)
27 1
28 >>> xor_gate(1, 1)
29 0
30 """
31 return (input_1, input_2).count(0) % 2
32
33
34if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

countMethod · 0.80

Tested by

no test coverage detected