import numpy as np
defAND(x1, x2):
x = np.array([x1, x2])
w = np.array([0.5,0.5])
b =-0.7
tmp = np.sum(w*x)+ b
if tmp <=0:return0else:return1
res = AND(0.7,0.3)print(res)
import numpy as np
defAND(x1, x2):
x = np.array([x1, x2])
w = np.array([0.5,0.5])
b =-0.7
tmp = np.sum(w*x)+ b
if tmp <=0:return0else:return1defNAND(x1, x2):
x = np.array([x1, x2])
w = np.array([-0.5,-0.5])
b =0.7
tmp = np.sum(w*x)+ b
if tmp <=0:return0else:return1defOR(x1, x2):
x = np.array([x1, x2])
w = np.array([0.5,0.5])
b =-0.2
tmp = np.sum(w*x)+ b
if tmp <=0:return0else:return1defXOR(x1, x2):
s1 = NAND(x1, x2)
s2 = OR(x1, x2)
y = AND(s1, s2)return y
res = XOR(1,0)print(res)