Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
14
Task/Truth-table/Python/truth-table.py
Normal file
14
Task/Truth-table/Python/truth-table.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from itertools import product
|
||||
|
||||
while True:
|
||||
bexp = input('\nBoolean expression: ')
|
||||
bexp = bexp.strip()
|
||||
if not bexp:
|
||||
print("\nThank you")
|
||||
break
|
||||
code = compile(bexp, '<string>', 'eval')
|
||||
names = code.co_names
|
||||
print('\n' + ' '.join(names), ':', bexp)
|
||||
for values in product(range(2), repeat=len(names)):
|
||||
env = dict(zip(names, values))
|
||||
print(' '.join(str(v) for v in values), ':', eval(code, env))
|
||||
Loading…
Add table
Add a link
Reference in a new issue