# ChapterLogic/truthTable.py """Logical operators: and( also &), or (also |), not p q p and q p or q 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 1 Table for your formula: p & (!q | !p): 0 0 0 0 1 0 1 0 True 1 1 False """ print('p','q','\tp and q','p or q') for p in range(2): for q in range(2): print(p,q,'\t',p and q,'\t',p or q) def formula(p,q): return (p and (not(q) or not(p))) def main(): print("Table for your formula: p & (!q | !p):") for p in range(2): # 0, 1 for q in range(2): print(p,q,'\t',formula(p,q)) main()