-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMcCulloch_Piits.py
More file actions
61 lines (53 loc) · 1.51 KB
/
McCulloch_Piits.py
File metadata and controls
61 lines (53 loc) · 1.51 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# define Unit Step Function
def Activation(v):
if v >= 1:
return 1
else:
return 0
def OR_Model(x1,x2):
s=x1+x2
if s>=1:
return 1
else:
return 0
def OR_3_Model(x1,x2,x3):
s=x1+x2+x3
if s>=1:
return 1
else:
return 0
def AND_Model(x1,x2):
s=x1+x2
if s>=2:
return 1
else:
return 0
def NOT_Model(x):
if x>=1:
return 1
else:
return 0
print("OR GATE:")
print("{}, {}= {}".format(0, 0, OR_Model(0,0)))
print("{}, {}= {}".format(0, 1, OR_Model(0,1)))
print("{}, {}= {}".format(1, 0, OR_Model(1,0)))
print("{}, {}= {}".format(1, 1, OR_Model(1,1)))
print()
print("AND GATE:")
print("{}, {}= {}".format(0, 0, AND_Model(0,0)))
print("{}, {}= {}".format(0, 1, AND_Model(0,1)))
print("{}, {}= {}".format(1, 0, AND_Model(1,0)))
print("{}, {}= {}".format(1, 1, AND_Model(1,1)))
print()
print("3 Input OR GATE:")
print("{}, {}, {}= {}".format(0, 0, 0, OR_3_Model(0,0,0)))
print("{}, {}, {}= {}".format(0, 0, 1, OR_3_Model(0,0,1)))
print("{}, {}, {}= {}".format(0, 1, 0, OR_3_Model(0,1,0)))
print("{}, {}, {}= {}".format(0, 1, 1, OR_3_Model(0,1,1)))
print("{}, {}, {}= {}".format(1, 0, 0, OR_3_Model(1,0,0)))
print("{}, {}, {}= {}".format(1, 0, 1, OR_3_Model(1,0,1)))
print("{}, {}, {}= {}".format(1, 1, 0, OR_3_Model(1,1,0)))
print("{}, {}, {}= {}".format(1, 1, 1, OR_3_Model(1,1,1)))
print()
print("NOT(0) = {}".format(NOT_Model(0)))
print("NOT(1) = {}".format(NOT_Model(1)))