Question

Develop a python program to simulate the operation of logic AND gate. You should use the...

Develop a python program to simulate the operation of logic AND gate. You should use the loop to operate the logic gate infinitely. This needs to implement one sequence as follows:
Loop
No LED (A and B) ON
PAUSE (2 seconds)
LED_A ON, LED_B OFF
PAUSE (2 seconds)
LED_B ON, LED_A OFF
PAUSE (2 seconds)
Both LEDs ON
PAUSE (2 seconds)
indicating 0 and 0
indicating 0 and 1
indicating 1 and 0
indicating 1 and 1

Homework Answers

Answer #1

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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
(In c code only, not c++) We will simulate the status of 8 LEDs that are...
(In c code only, not c++) We will simulate the status of 8 LEDs that are connected to a microcontroller. Assume that the state of each LED (ON or OFF) is determined by each of the bits (1 or 0) in an 8-bit register (high-speed memory). Declare a char variable called led_reg and initialize it to 0. Assume that the least-significant bit (lsb) controls LED#0 and the most-significant bit (msb) controls LED#7. In the main function, build and present a...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with the random numbers between 1 and 9 (including 0 and 9). - Assume that you are located at (0,0) (upper-left corner) and want to move to (9,9) (lower-right corner) step by step. In each step, you can only move right or down in the array. - Develop a function to simulate random movement from (0,0) to (9,9) and return sum of all cell values...
Objective: The objective of this practical exercise is to introduce to develop a ladder diagram from...
Objective: The objective of this practical exercise is to introduce to develop a ladder diagram from a word problem using interlocking and safety operation techniques. Equipment: ·         Computer with installed software to control and program the PLC Process Application: Water Tank Level The process shown in the Figure below is to be used to control the level of water in a storage tank by turning a discharge pump on or off. The modes of operation are to be programmed as...
In this module you learned about making decisions. You learned about the syntax and rules used...
In this module you learned about making decisions. You learned about the syntax and rules used to develop programs containing decisions and how the logic can make your programs more robust. Draw a flowchart for a program that shows the logic for a program that generates a random number. The program will simulate tossing coin. The program should generate a random number(0 and 1). If the random number is 0, then it should display the word "Heads". If the random...
Develop a python program to find the different solutions, i.e. zero crossings, of a polynomial function...
Develop a python program to find the different solutions, i.e. zero crossings, of a polynomial function using Newton-Raphson’s method over a given range. To do this we will develop three functions: the first should be a function to evaluate the polynomial at a given value of the independent variable; the second function would evaluate the derivative of the polynomial at a given value of the independent variable; finally, the third function would implement Newton-Raphson’s (NR) method to determine a zero...
Language: Python Write a program to simulate an experiment of tossing a fair coin 16 times...
Language: Python Write a program to simulate an experiment of tossing a fair coin 16 times and counting the number of heads. Repeat this experiment 10**5 times to obtain the number of heads for every 16 tosses; save the number of heads in a vector of size 10**5 (call it headCounts). You should be able to do this in 1-3 lines of numpy code. (Use np.random.uniform1 to generate a 2d array of 10**5 x 16 random numbers between 0 and...
# Question 2 for HW 3 use MPLAB IDE # Your solution should implement the following...
# Question 2 for HW 3 use MPLAB IDE # Your solution should implement the following loop: # for (i = 0; i < X; i++) { # A = A + X; # B = B - X; # if (A == B) # break; ## break exits loop early # } .global main .data ### THESE VARIABLES ARE SIMPLY GIVEN VALUES TO START ### WITH--CHANGE THEIR VALUES AND VERIFY YOUR PROGRAM ### WORKS APPROPRIATELY IN ALL CASES A:...
For PYTHON program you will be writing a program that will use if-else or if-elif-else statements....
For PYTHON program you will be writing a program that will use if-else or if-elif-else statements. Read-It-All bookstore has a book sales club where customers can earn reward points that can be used for their next purchase. If a customer purchases 0 books, he/she earns 0 points. If a customer purchases 1-3 books, he/she earns 5 points. If a customer purchases 4-6 books, he/she earns 10 points. If a customer purchases 7-8 books, he/she earns 15 points. If a customer...
USE PYTHON LANGUAGE PLEASE FOCUS YOU SHOULD ENTER AN ARRAY AND THEN THE PROGRAM GIVE OUTPUT(...
USE PYTHON LANGUAGE PLEASE FOCUS YOU SHOULD ENTER AN ARRAY AND THEN THE PROGRAM GIVE OUTPUT( TRUE/ FALSE) QUIZ 8 Array Challenge Have the function ArrayChallenge(arr) take the array of numbers stored in arr and return the string true if any two numbers can be multiplied so that the answer is greater than double the sum of all the elements in the array. If not, return the string false. For example: if arr is [2, 5, 6, -6, 16, 2,...
In Python: This will require you to write several functions, and then use them in a...
In Python: This will require you to write several functions, and then use them in a program. Logical Calculator The logical calculator does math, but with logical operators. In logic, we represent a bit with 0 as false and a bit with 1 as true. The logical operators are NOT, AND and OR. Bitwise logical calculations operate on each bit of the input. The NOT operator works on just one three-bit argument. NOT 011 = 100 The AND operator works...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT