Maker Pro
Maker Pro

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

shivajikobardan

Oct 21, 2021
39
Joined
Oct 21, 2021
Messages
39
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:
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:
https://i.stack.imgur.com/e68IX.png
What are we expecting in output condition in this case?
I will explain it with a figure:
https://i.stack.imgur.com/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.
https://electronics.stackexchange.c...ive-why-should-i-use-or-gate-in/596643#596643
 

Nanren888

Nov 8, 2015
622
Joined
Nov 8, 2015
Messages
622
Sorry, I am rather at a loss about what you want help with.
Your reference cites De Morgan's Law which is the key to using an or gate for an and condition.
You have drawn the truth tables for the two inpuit conditions (x<1) and for (x>10)
Your code is reversible in that you could check for either (x<1)||(x>10) or otherwise (1<=x)&&(10<=x) and reverse the error and the OK.
.
I guess most people write circuits to indicate their "correct", "OK" condition. But errror detectors are of course useful.
.
I think that I would have tried to say basically what the stackexchange answer did. It seems to answer all the things you talk about.
Have I helped.
If not, perhaps you could elaborate on which art you are missing.
.
BTW: sometimes there is merit in the learnign that comes with sorting out your answer before googling or stack exchange :)

I know the answer,
The answer is sometimes the recognition of method, or understanding.
Enjoy.
 
Top