not (True and True or not False)
def or_function(first, second):
if first:
return first
else:
return second
def and_function(first, second):
if not first:
return first
else:
return second
>>> possibilities = ((0, 0), (0, 1), (1, 0), (1, 1))
>>> for first, second in possibilities:
print first, second, '|', or_function(first, second), first or second
0 0 | 0 0
0 1 | 1 1
1 0 | 1 1
1 1 | 1 1
>>>
>>> for first, second in possibilities:
print first, second, '|', and_function(first, second), first and second
0 0 | 0 0
0 1 | 0 0
1 0 | 0 0
1 1 | 1 1
Users browsing this forum: Baidu [Spider], W3C [Linkcheck] and 3 guests