From 927fc55ba9d6bca9cc4981f157ccd33bbbad9029 Mon Sep 17 00:00:00 2001 From: robohie Date: Fri, 9 May 2025 15:57:07 +0100 Subject: [PATCH 1/5] Update and_gate.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit J'ai nourri ce programme en ajoutant une porte And à n entrées. --- boolean_algebra/and_gate.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/boolean_algebra/and_gate.py b/boolean_algebra/and_gate.py index 6ae66b5b0a77..3991d0042c95 100644 --- a/boolean_algebra/and_gate.py +++ b/boolean_algebra/and_gate.py @@ -32,6 +32,18 @@ def and_gate(input_1: int, input_2: int) -> int: return int(input_1 and input_2) +def n_and_gate(inputs: tuple) -> int: + """ + Calcul le And de la liste des nombres + binaires fournie. Nécessaire pour + implémenter une porte And à n entrées + Par exemple + >>> n_and_gate((1, 0, 1, 1, 0)) + 0 + """ + return int(all(inputs)) + + if __name__ == "__main__": import doctest From c54f7bbc9a51f7e0b25b3f0527319da3c3aceed6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 15:07:11 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- boolean_algebra/and_gate.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/boolean_algebra/and_gate.py b/boolean_algebra/and_gate.py index 3991d0042c95..9c09b7b2e219 100644 --- a/boolean_algebra/and_gate.py +++ b/boolean_algebra/and_gate.py @@ -33,15 +33,15 @@ def and_gate(input_1: int, input_2: int) -> int: def n_and_gate(inputs: tuple) -> int: - """ - Calcul le And de la liste des nombres - binaires fournie. Nécessaire pour - implémenter une porte And à n entrées - Par exemple - >>> n_and_gate((1, 0, 1, 1, 0)) - 0 - """ - return int(all(inputs)) + """ + Calcul le And de la liste des nombres + binaires fournie. Nécessaire pour + implémenter une porte And à n entrées + Par exemple + >>> n_and_gate((1, 0, 1, 1, 0)) + 0 + """ + return int(all(inputs)) if __name__ == "__main__": From 7072b86b42493909590a88989fa3cb8ca773bc8f Mon Sep 17 00:00:00 2001 From: robohie Date: Fri, 9 May 2025 16:13:00 +0100 Subject: [PATCH 3/5] Update and_gate.py Commentaires en anglais --- boolean_algebra/and_gate.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/boolean_algebra/and_gate.py b/boolean_algebra/and_gate.py index 9c09b7b2e219..58175fb0541b 100644 --- a/boolean_algebra/and_gate.py +++ b/boolean_algebra/and_gate.py @@ -34,10 +34,8 @@ def and_gate(input_1: int, input_2: int) -> int: def n_and_gate(inputs: tuple) -> int: """ - Calcul le And de la liste des nombres - binaires fournie. Nécessaire pour - implémenter une porte And à n entrées - Par exemple + Calculate AND of a list of input values + >>> n_and_gate((1, 0, 1, 1, 0)) 0 """ From 9b2962620e61937ed6fc8ab5e92395969422871f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 15:17:58 +0000 Subject: [PATCH 4/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- boolean_algebra/and_gate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boolean_algebra/and_gate.py b/boolean_algebra/and_gate.py index 58175fb0541b..15133be9cc0b 100644 --- a/boolean_algebra/and_gate.py +++ b/boolean_algebra/and_gate.py @@ -35,7 +35,7 @@ def and_gate(input_1: int, input_2: int) -> int: def n_and_gate(inputs: tuple) -> int: """ Calculate AND of a list of input values - + >>> n_and_gate((1, 0, 1, 1, 0)) 0 """ From 6806a7a0cd60e9d6671c1549c153fca241889af2 Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Sat, 10 May 2025 14:44:03 +0300 Subject: [PATCH 5/5] Update and_gate.py --- boolean_algebra/and_gate.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/boolean_algebra/and_gate.py b/boolean_algebra/and_gate.py index 15133be9cc0b..650017b7ae10 100644 --- a/boolean_algebra/and_gate.py +++ b/boolean_algebra/and_gate.py @@ -1,8 +1,8 @@ """ -An AND Gate is a logic gate in boolean algebra which results to 1 (True) if both the -inputs are 1, and 0 (False) otherwise. +An AND Gate is a logic gate in boolean algebra which results to 1 (True) if all the +inputs are 1 (True), and 0 (False) otherwise. -Following is the truth table of an AND Gate: +Following is the truth table of a Two Input AND Gate: ------------------------------ | Input 1 | Input 2 | Output | ------------------------------ @@ -12,7 +12,7 @@ | 1 | 1 | 1 | ------------------------------ -Refer - https://www.geeksforgeeks.org/logic-gates-in-python/ +Refer - https://www.geeksforgeeks.org/logic-gates/ """ @@ -32,12 +32,14 @@ def and_gate(input_1: int, input_2: int) -> int: return int(input_1 and input_2) -def n_and_gate(inputs: tuple) -> int: +def n_input_and_gate(inputs: list[int]) -> int: """ Calculate AND of a list of input values - >>> n_and_gate((1, 0, 1, 1, 0)) + >>> n_input_and_gate([1, 0, 1, 1, 0]) 0 + >>> n_input_and_gate([1, 1, 1, 1, 1]) + 1 """ return int(all(inputs))