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

Function n_input_and_gate

boolean_algebra/and_gate.py:35–44  ·  view source on GitHub ↗

Calculate AND of a list of input values >>> n_input_and_gate([1, 0, 1, 1, 0]) 0 >>> n_input_and_gate([1, 1, 1, 1, 1]) 1

(inputs: list[int])

Source from the content-addressed store, hash-verified

33
34
35def n_input_and_gate(inputs: list[int]) -> int:
36 """
37 Calculate AND of a list of input values
38
39 >>> n_input_and_gate([1, 0, 1, 1, 0])
40 0
41 >>> n_input_and_gate([1, 1, 1, 1, 1])
42 1
43 """
44 return int(all(inputs))
45
46
47if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected