TheAlgorithms-Python

Форк
0
35 строк · 887.0 Байт
1
"""
2
An OR Gate is a logic gate in boolean algebra which results to 0 (False) if both the
3
inputs are 0, and 1 (True) otherwise.
4
Following 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
    ------------------------------
13
Refer - https://www.geeksforgeeks.org/logic-gates-in-python/
14
"""
15

16

17
def or_gate(input_1: int, input_2: int) -> int:
18
    """
19
    Calculate OR of the input values
20
    >>> or_gate(0, 0)
21
    0
22
    >>> or_gate(0, 1)
23
    1
24
    >>> or_gate(1, 0)
25
    1
26
    >>> or_gate(1, 1)
27
    1
28
    """
29
    return int((input_1, input_2).count(1) != 0)
30

31

32
if __name__ == "__main__":
33
    import doctest
34

35
    doctest.testmod()
36

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.