-
Notifications
You must be signed in to change notification settings - Fork 0
/
explain.py
42 lines (40 loc) · 1.55 KB
/
explain.py
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
33
34
35
36
37
38
39
40
41
42
from color_print import color_print
def explain():
color_print('blue', '[AND] [OR] [XOR] [NAND] [NOR]')
input_gate = input('gate ')
if input_gate == 'and':
print('\n' + '-' * 12)
print(' AND-gate')
print('-' * 12)
print('The AND-gate returns 1 only if both inputs are 1')
print(' ______ ')
print(' A ---| \ 0 0 | 0')
print(' | AND )--- OUT 1 0 | 0')
print(' B ---|______/ 0 1 | 0')
print(' 1 1 | 1')
print()
elif input_gate == 'or':
print('\n' + '-' * 12)
print(' OR-gate')
print('-' * 12)
print('The OR-gate returns 1 if one OR both inputs are 1')
print(' ______ ')
print(' A ---\ \ 0 0 | 0')
print(' ) OR )--- OUT 1 0 | 1')
print(' B ---/______/ 0 1 | 1')
print(' 1 1 | 1')
print()
elif input_gate == 'nand':
print('\n' + '-' * 12)
print(' NAND-gate')
print('-' * 12)
print('The NAND-gate returns the inverse of an AND-gate.')
print('1 only if both inputs are 1')
print(' ______ ')
print(' A ---\ \ 0 0 | 0')
print(' ) NAND )--- OUT 1 0 | 1')
print(' B ---/______/ 0 1 | 1')
print(' 1 1 | 1')
print()
else:
print('\n# TODO', end='\n\n')