Question: Write a program in Python 3.8 representing 7 logic gates: AND NAND OR NOR XOR XNOR NOT Accept (only) two inputs to create all outputs.

Write a program in Python 3.8 representing 7 logic gates:

  • AND
  • NAND
  • OR
  • NOR
  • XOR
  • XNOR
  • NOT
  1. Accept (only) two inputs to create all outputs.
  2. Use the if statement to perform the Boolean logic.
  3. Only accept numeric input.
  4. If a number is greater than 0 treat it as a 1.
  5. Specify in your output and in the beginning of the code (through print statements) which gate the code represents.
  6. Comment your code.

Please Explain how you do it please. Thanks. I am mostly confused on how to program a number greater than 0 to be treated as a 1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!