1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ilia_Sergeevich [38]
3 years ago
15

What does this mean in python?

Computers and Technology
1 answer:
scoundrel [369]3 years ago
8 0

the comments in the code should explain everything, brainly's formatting might be weird


gate = raw_input("Enter logic gate :").upper()#.upper() so lower/upper case of input doesn't matter

firstInput = raw_input("Enter first input :")#raw_input() for python 2.7, input() for 3

secondInput = raw_input("Enter second input :")

if (firstInput!="0" and firstInput!="1") or (secondInput!="0" and secondInput!="1"):

print("inputs must be 0 or 1")#ensure all inputs are in boolean range

quit()


firstInput=firstInput=="1"#convert "1" to true and "0" to false

secondInput=secondInput=="1"


if gate=="AND" or gate=="NAND":

result=firstInput and  secondInput

elif gate=="OR" or gate=="NOR":

result=firstInput or secondInput

elif gate=="XOR":

result=firstInput!=secondInput

else:#handle case of unknown/mistyped gates

print(gate+" is not known")

quit()

if gate=="NOR" or gate=="NAND":

result=not result#invert result for nor and nand

print("Result = "+str(int(result)))#uses int so 1/0 are printed instead of True/False


You might be interested in
How many months have 28 days?
Reika [66]

Answer:

All months of the year have at least 28 days, while February is the only month that is comprised of only 28 days (except for leap years)

5 0
3 years ago
Evan accidentally entered an incorrect word when he was typing a document. Which keyboard shortcut should he use to undo the err
agasfer [191]
CTRL Z is the redo action so thats your best bet
8 0
3 years ago
Read 2 more answers
What is parallelism of microinstruction
Kitty [74]
The answer is Hardware level works upon dynamic parallelism whereas, the software level works on static parallelism. Dynamic parallelism means the processor decides at run time which instructions to execute in parallel,
8 0
3 years ago
Ou are a web page designer and you set up a page with five different links. a user of the page can click on one of the links or
sertanlavr [38]

There are 6 possible outcomes and they are :

S={link1,link2,link3,link4,link5,leave}

this is the sample space for the outcome of a visitor to your webpage.

8 0
3 years ago
One of the most basic agricultural tools is the tractor, which is designed to break up the soil in order to prepare it for plant
melisa1 [442]
False because the tractor doesn’t break up the soil
4 0
3 years ago
Other questions:
  • Problem Overview You have just moved into a new home, and you have brought all your digital communications devices. After contac
    10·1 answer
  • Question 3 / 5
    9·1 answer
  • A computer that stores and distributes newsgroup messages is called a newsreader.
    13·1 answer
  • Look at the following list of peripheral items and determine what type they are: mouse, keyboard, webcam, microphone. Input Outp
    15·1 answer
  • What can be done in order to secure a WLAN/wireless access point?
    12·1 answer
  • What is an end user license (EULA) agreement an example of?
    9·2 answers
  • Explain the use of cache memory and the role it plays in improving processing speeds. Plz
    15·2 answers
  • What is the advantage of processor affinity on SMP computers ?
    14·1 answer
  • Please answer<br><br>NO LINKS​
    7·1 answer
  • Select examples of software
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!