CM 6.2 Mrg Logic 2011.1222

3627 days ago by calcpage123

print "p","\tq","\tp and q" for p in range(2): for q in range(2): print p, "\t", q, "\t", p and q 
       
p 	q 	p and q
0 	0 	0
0 	1 	0
1 	0 	0
1 	1 	1
p 	q 	p and q
0 	0 	0
0 	1 	0
1 	0 	0
1 	1 	1
print "p","\tq","\tp or q" for p in range(2): for q in range(2): print p, "\t", q, "\t", p or q 
       
p 	q 	p or q
0 	0 	0
0 	1 	1
1 	0 	1
1 	1 	1
p 	q 	p or q
0 	0 	0
0 	1 	1
1 	0 	1
1 	1 	1
print "p","\t~p" for p in range(2): print p, "\t", int(not p) 
       
p 	~p
0 	1
1 	0
p 	~p
0 	1
1 	0
#Proove DeMorgan's Law # ~(p * q) = ~p + ~q print "p","\tq","\t~p","\t~q","\tp and q","\tnot(p and q)" for p in range(2): for q in range(2): print p,"\t",q,"\t",int(not p),"\t",int(not q),"\t",p and q,"\t\t",int(not(p and q)) 
       
p 	q 	~p 	~q 	p and q 	not(p and q)
0 	0 	1 	1 	0 		1
0 	1 	1 	0 	0 		1
1 	0 	0 	1 	0 		1
1 	1 	0 	0 	1 		0
p 	q 	~p 	~q 	p and q 	not(p and q)
0 	0 	1 	1 	0 		1
0 	1 	1 	0 	0 		1
1 	0 	0 	1 	0 		1
1 	1 	0 	0 	1 		0
print "p","\tq","\t~p","\t~q","\tnot p or not q" for p in range(2): for q in range(2): print p,"\t",q,"\t",int(not p),"\t",int(not q),"\t",int(not p or not q) 
       
p 	q 	~p 	~q 	not p or not q
0 	0 	1 	1 	1
0 	1 	1 	0 	1
1 	0 	0 	1 	1
1 	1 	0 	0 	0
p 	q 	~p 	~q 	not p or not q
0 	0 	1 	1 	1
0 	1 	1 	0 	1
1 	0 	0 	1 	1
1 	1 	0 	0 	0