TheAlgorithms-Python
35 строк · 887.0 Байт
1"""
2An OR Gate is a logic gate in boolean algebra which results to 0 (False) if both the
3inputs are 0, and 1 (True) otherwise.
4Following is the truth table of an AND Gate:
5------------------------------
6| Input 1 | Input 2 | Output |
7------------------------------
8| 0 | 0 | 0 |
9| 0 | 1 | 1 |
10| 1 | 0 | 1 |
11| 1 | 1 | 1 |
12------------------------------
13Refer - https://www.geeksforgeeks.org/logic-gates-in-python/
14"""
15
16
17def or_gate(input_1: int, input_2: int) -> int:
18"""
19Calculate OR of the input values
20>>> or_gate(0, 0)
210
22>>> or_gate(0, 1)
231
24>>> or_gate(1, 0)
251
26>>> or_gate(1, 1)
271
28"""
29return int((input_1, input_2).count(1) != 0)
30
31
32if __name__ == "__main__":
33import doctest
34
35doctest.testmod()
36