Code :
import time ## importing time library so as to pause for 2
seconds
def logic_and ():
flag=1
while (flag): ## This loop will run infinitely as we
want operate logic gate infinitely.
print ("0 0") ## print (0 0) Both LED are off
time.sleep(2); ## Given a pause of 2 seconds
print("0 1") ## print (0 1) LED A is On and B is
off
time.sleep(2);
print("1 0") ## print (1 0) LED B is On and A is
off
time.sleep(2);
print("1 1") ## print (1 1) Both LED are on
time.sleep(2);
logic_and() ## This will call the above function
Output :
The loop will keep on performing operations of and gate till infinity.
Get Answers For Free
Most questions answered within 1 hours.