""" truth_table.py Use brute force to see if A and (B or C) is the same as (A and B) or C """ def tf(x): # """ Return T, F for True, False """ if x: return 'T' else: return 'F' def print_one_line(A, B, C): """ print one line of the truth table """ a_and_stuff = A and (B or C) stuff_or_c = (A and B) or C print " {} | {} | {} => {} | {}".format( tf(A), tf(B), tf(C), tf(a_and_stuff), tf(stuff_or_c) ) def main(): for A in (True, False): for B in (True, False): for C in (True, False): print_one_line(A, B, C) main()