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

Function and_gate

boolean_algebra/and_gate.py:19–32  ·  view source on GitHub ↗

Calculate AND of the input values >>> and_gate(0, 0) 0 >>> and_gate(0, 1) 0 >>> and_gate(1, 0) 0 >>> and_gate(1, 1) 1

(input_1: int, input_2: int)

Source from the content-addressed store, hash-verified

17
18
19def and_gate(input_1: int, input_2: int) -> int:
20 """
21 Calculate AND of the input values
22
23 >>> and_gate(0, 0)
24 0
25 >>> and_gate(0, 1)
26 0
27 >>> and_gate(1, 0)
28 0
29 >>> and_gate(1, 1)
30 1
31 """
32 return int(input_1 and input_2)
33
34
35def n_input_and_gate(inputs: list[int]) -> int:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected