-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathLogic Gates.py
64 lines (57 loc) · 1.36 KB
/
Logic Gates.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import time
l1=[0,0,1,1]
l2=[0,1,0,1]
orgate=[]
andgate=[]
xorgate=[]
def and_gate():
for i in range(len(l1)):
count=0
if l1[i]==1 and l2[i]==1:
count=0
time.sleep(1)
print('---->',count)
andgate.append(count)
else:
count+=1
time.sleep(1)
print('---->',count)
andgate.append(count)
def or_gate():
for i in range(len(l1)):
count=0
if l1[i]==1:
count+=1
time.sleep(1)
print('---->',count)
orgate.append(count)
elif l2[i]==1:
count+=1
time.sleep(1)
print('---->',count)
orgate.append(count)
else:
count=0
time.sleep(1)
print('---->',count)
orgate.append(count)
def xor_gate():
for i in range(len(l1)):
count=0
if l1[i]!=l2[i]:
count+=1
time.sleep(1)
print('---->',count)
xorgate.append(count)
else:
count=0
time.sleep(1)
print('---->',count)
xorgate.append(count)
print(' LOGIC GATES ')
print('Or Gate: ',orgate)
or_gate()
print('And Gate: ',andgate)
and_gate()
print('Xor Gate: ',xorgate)
xor_gate()