Modify the Simple Circuit with Functions program so that the user will error trap for only 1 and 0 as an input.   If the user enters an input other than 1 or 0 display an error message and request the user enter that input again.  Do this for all inputs in the code

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

In Python

Modify the Simple Circuit with Functions program so that the user will error trap for only 1 and 0 as an input.  

If the user enters an input other than 1 or 0 display an error message and request the user enter that input again.  Do this for all inputs in the code.  Produce a flowchart.  

 

from random import randint
x = randint (0,1)
y = randint (0,1)
z = randint (0,1)
def NORGate (a,b) :
if a == 1 or b --
l:
norGate = 0
else:
norGate = 1
return norGate
def ANDGate (b, c) :
if b == 1 and c
=D
andGate = 1
else:
andGate = 0
return andGate
def XORGate (a,b) :
if a != b:
xorGate - 1
else:
xorGate = 0
return xorGate
ans = NORGate (x, y)
ans2 - ANDGate (y, z)
ans3 = XORGate (ans, ans2)
print (x, y, z)
print ("NORGate - a and c is:"
print ("ANDGate
print ("XORGate
ans)
b and c is:"
• ans2)
both answers are:"
ans3)
Transcribed Image Text:from random import randint x = randint (0,1) y = randint (0,1) z = randint (0,1) def NORGate (a,b) : if a == 1 or b -- l: norGate = 0 else: norGate = 1 return norGate def ANDGate (b, c) : if b == 1 and c =D andGate = 1 else: andGate = 0 return andGate def XORGate (a,b) : if a != b: xorGate - 1 else: xorGate = 0 return xorGate ans = NORGate (x, y) ans2 - ANDGate (y, z) ans3 = XORGate (ans, ans2) print (x, y, z) print ("NORGate - a and c is:" print ("ANDGate print ("XORGate ans) b and c is:" • ans2) both answers are:" ans3)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY