Skip to content

Commit 927fc55

Browse files
authored
Update and_gate.py
J'ai nourri ce programme en ajoutant une porte And à n entrées.
1 parent d9d56b1 commit 927fc55

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

boolean_algebra/and_gate.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ def and_gate(input_1: int, input_2: int) -> int:
3232
return int(input_1 and input_2)
3333

3434

35+
def n_and_gate(inputs: tuple) -> int:
36+
"""
37+
Calcul le And de la liste des nombres
38+
binaires fournie. Nécessaire pour
39+
implémenter une porte And à n entrées
40+
Par exemple
41+
>>> n_and_gate((1, 0, 1, 1, 0))
42+
0
43+
"""
44+
return int(all(inputs))
45+
46+
3547
if __name__ == "__main__":
3648
import doctest
3749

0 commit comments

Comments
 (0)