Question: Problem 3 This section is to work on logic, functions, and circuits. Look at the figure below of the circuit. Your task is to write
Problem 3 This section is to work on logic, functions, and circuits. Look at the figure below of the circuit. Your task is to write a function circuit(A, B, c) that takes A, B, and C and returns the value indicated by the circuit. The dotted box surrounds a circuit Z as well-It's made of only two gates, but takes the same inputs. You can write a local function Z that makes this problem easier. The partial code and output are shown below OUTPUT Figure 3: A circuit with inputs A, B, and C. The dotted box encloses another circuit that can be treated as its own function locally Listing 3: circuit.py program 1 def circuit(A, B, C): 2 def Z(a, b, c): return #1 return #2 6 print (0,0,0,circuit(0,0,0)) 7 print (0,0,1,circuit(0,0,1)) 8 print (0,1,0,circuit(0,1,0)) 9 print(0,1,1,circuit (0,1,1)) 10 print(1,0,0,circuit(1,0,0)) 11 print (1,0,1,circuit(1,0,1)) 12 print(1,1,0,circuit(1,1,0)) 13 print (1,1,1,circuit(1,1,1)) Output circuit.py 0 00 True 0 0 1 False Problem 3 This section is to work on logic, functions, and circuits. Look at the figure below of the circuit. Your task is to write a function circuit ( A, B, C) that takes A, B, and C and returns the value indicated by the circuit. The dotted box surrounds a circuit Z as well-Ht's two gates, but takes the same inputs. You can write a local function Z that makes this problem easier. The partial code and output are shown below. made of only OUTPUT Figure 3: A circuit with inputs A, B, and C. The dotted box encloses another circuit that can b treated as its own function locally. Listing 3: circuit.py program 1 def circuit(A, B, C): 2 def Z(a, b, c): return #1 return #2 print(0,0,0,circuit (0,0,0)) print (0,0,1,circuit(0,0,1)) print(0,1,0,circuit(0,1,0)) print(0,1,1,circuit (0,1,1)) print (1,0,0,circuit(1,0,0)) print (1,0,1,circuit (1,0,1)) print (1,1,0,circuit(1,1,0)) print(1,1,1,circuit(1,1,1)) Output circuit.py 0 0 0 True
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
