Lichen

tests/logical.py

1025:d84d7a6f3c87
5 months ago Paul Boddie Merged changes from the trailing-data branch. value-replacement
     1 def f(a, b, c):     2     return a and b and c     3      4 def g(a, b, c):     5     return a or b or c     6      7 def h(a, b, c):     8     return a and b or c     9     10 def i(a, b, c):    11     return a or b and c    12     13 def j(a, b, c):    14     return f(a, b, c) and g(a, b, c) or c    15     16 print f(0, 0, 0)            # 0    17 print f(1, 0, 1)            # 0    18 print f(1, 1, 1)            # 1    19     20 print g(0, 0, 0)            # 0    21 print g(1, 0, 0)            # 1    22 print g(0, 0, 1)            # 1    23     24 print h(0, 0, 0)            # 0    25 print h(0, 0, 1)            # 1    26 print h(1, 0, 0)            # 0    27     28 print i(0, 0, 0)            # 0    29 print i(0, 0, 1)            # 0    30 print i(1, 0, 0)            # 1    31     32 print j(0, 0, 0)            # 0    33 print j(0, 0, 1)            # 1    34 print j(1, 0, 0)            # 0    35     36 # Test any and all functions.    37     38 l = [0, 0, 1, 0, 0]    39 print any(l)                # True    40 print all(l)                # False    41     42 l = [1, 1, "one", 1]    43 print any(l)                # True    44 print all(l)                # True    45     46 l = [1, 1, "one", ""]    47 print any(l)                # True    48 print all(l)                # False