1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
from sympy import * A, B, C, D, F, F2 = symbols('A, B, C, D, F, F2') print('N A B C D | F')
bool_list = [] for i in range(16): tmp_list = [] str = '{0:0>4b}'.format(i) for j in range(4): num = int(str[j]) tmp_list.append(num) bool_list.append(tmp_list)
num = 0 for eachone in bool_list: print('{0:<4}'.format(num), end='') num += 1 for j in eachone: print('{0:<3}'.format(j), end='') F = (A | B | (C & D)).subs({A:eachone[0], B:eachone[1], C:eachone[2], D:eachone[3]}) each_res = 1 if F == True else 0 print('{0:<3}'.format('|'), end='') print('{0:<3}'.format(each_res), end='') print()
|