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...
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...
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...
For Java For this assignment you will develop two classes called ATM and Customer that simulate...
For Java For this assignment you will develop two classes called ATM and Customer that simulate an imaginary automated teller machine (ATM). In the assignment, you should also develop a UML class diagram for the ATM class and a jUnit test case. In the program, we assume that an ATM initially keeps $100.00 cash for customer transactions. Additionally, we assume that there are a total of ten customers combined for the Union Bank and BOA banks. This is a list...
***Python Hailstones, also known as the Collatz sequence, are a mathematical curiosity. For any number in...
***Python Hailstones, also known as the Collatz sequence, are a mathematical curiosity. For any number in the sequence, the next number in the sequence is determined by two simple rules: If the current number n is odd, the next number in the sequence is equal to 3 * n + 1 If the current number n is even instead, the next number in the sequence is equal to one half of n (i.e., n divided by 2) We repeat this...
Section 2: Using the MARS or SPIM simulator develop a program that will implement the following...
Section 2: Using the MARS or SPIM simulator develop a program that will implement the following conditional statement. If ( n is even) { n = n / 2; } else { n = 3 * n + 1; } In this case, n is to be input by the user (assume they input a non-negative value), the conditional is performed, and the resulting n is to be output. Again, use the system calls for input, output, and exiting the...