Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

We want numbers that lie between 1 and 10 inclusive what is the truth table that we are expecting?

Status
Not open for further replies.
I know the answer, I need to use an OR gate because that is how the code works. I want to learn the problem solving part of this.

The code that works is:


Python:
  if(x<1 or x>10):
         print("Error")
    else:
         print("Ok")


Also and gate works if used differently. but I am unable to figure out the problem solving part of it. i.e figuring out how to decide what to use. that is what is confusing me. and this is very common thing in programming. very important as well.

I know the truth tables of OR and AND gate as well:

e68IX.png


What are we expecting in output condition in this case?

I will explain it with a figure:

6rr9O.png


What is the condition we are expecting there? What is needed to be either true or false in output condition ? Can you clarify that much?


This is such a basic question but it is affecting my programming skills too much vividly. I am unable to figure out what condition are we trying to find in output?? I asked this question here as well, but didn't get my answer that I was trying to get.

 
Last edited:
Look at the binary bit values for each number:-
8 4 2 1

Greater than ten:
Bits 8 AND 2 AND 1 (11) OR Bits 8 AND 4 (12 & up).

Less than 1: All bits 0; a four input NOR gate would work

OR that output with the >10 result to get the overall error signal.
(The "between 1-10 inclusive" signal is the inverse of the error signal).
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top