Skip to content

Commit 6806a7a

Browse files
Update and_gate.py
1 parent 9b29626 commit 6806a7a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

boolean_algebra/and_gate.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
2-
An AND Gate is a logic gate in boolean algebra which results to 1 (True) if both the
3-
inputs are 1, and 0 (False) otherwise.
2+
An AND Gate is a logic gate in boolean algebra which results to 1 (True) if all the
3+
inputs are 1 (True), and 0 (False) otherwise.
44
5-
Following is the truth table of an AND Gate:
5+
Following is the truth table of a Two Input AND Gate:
66
------------------------------
77
| Input 1 | Input 2 | Output |
88
------------------------------
@@ -12,7 +12,7 @@
1212
| 1 | 1 | 1 |
1313
------------------------------
1414
15-
Refer - https://www.geeksforgeeks.org/logic-gates-in-python/
15+
Refer - https://www.geeksforgeeks.org/logic-gates/
1616
"""
1717

1818

@@ -32,12 +32,14 @@ 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:
35+
def n_input_and_gate(inputs: list[int]) -> int:
3636
"""
3737
Calculate AND of a list of input values
3838
39-
>>> n_and_gate((1, 0, 1, 1, 0))
39+
>>> n_input_and_gate([1, 0, 1, 1, 0])
4040
0
41+
>>> n_input_and_gate([1, 1, 1, 1, 1])
42+
1
4143
"""
4244
return int(all(inputs))
4345

0 commit comments

Comments
 (0)