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

#### shivajikobardan

##### New Member
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:

What are we expecting in output condition in this case?

I will explain it with a figure:

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:

#### rjenkinsgb

##### Well-Known Member
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).

Replies
7
Views
9K
Replies
5
Views
2K
Replies
7
Views
1K
Replies
9
Views
2K
Replies
15
Views
2K