Gorege Boole tossed the concept of Boolean Algebra
and said one can represent any logical statement with AND, OR, NOT
Basic Logic is in their name
Starting with AND
assume AND as a 5-year-old child who demands telescope π and Starshipπ, so if you provide him with both stuff he will be happy, and if anyone or both aren't there the child will start crying.
Similar with AND if it say I want value x > 3 & y < 5
then the condition will only satisfy if both stuff are true
Telescope π | Starship π | Output Q |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Moving towards OR
the same child here also, where now he demand Falcon 9 OR Saturn 5 as he wants to Mars. So, if you provide him Falcon 9 he will be happy as his Mission will be completed with Falcon 9, but show you aren't able to contact Elon to arrange Falcon 9 but you are able to contact NASA for Saturn 5 even then the 5 yr Child will be happy. Also, if you provided him with both Falcon 9 and Saturn 5 he will be happy as now he can talk to the crew too.
Similar, to OR, if it wants Falcon 9 || Saturn 5
if it gets Falcon 9 it will be satisfied even if it got Saturn 5 he will be satisfied, but it won't satisfy if both are False
Falcon 9π | Saturn 5 πͺπ | Output Q |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
Now comes NOT
not is very simple to understand, it is used to negate the condition, so if just convert's the value of the condition, from true to false and false to true.
| Input A | Input B |
|:-------:|:-------:|
| 0 | 1 |
| 1 | 0 |
Now comes XOR
, NAND
, NOR
above basics.
XOR
XOR
only wants one true value to be true, example the child only wants SpaceX or Saturn 5 but not both, if you give both he will break the rocket in two pieces, so please with XOR you can only give him one of them.
Input A | Input B | Output Q |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
NOR
A situation where one except's nothing from anyone, the child is now grown up, now he doesn't need your help to build a complete rocket. If you don't give him anything he will be happy,
Input A | Input B | Output Q |
---|---|---|
0 | 0 | 1β |
0 | 1 | 0β |
1 | 0 | 0β |
1 | 1 | 0β |
NAND
Here the child doesn't want both things from you he only even if you don't give anything to him he will be happy, but if you give him both he will cry, but you can give one of any.
Input A | Input B | Output Q |
---|---|---|
0 | 0 | 1β |
0 | 1 | 1β |
1 | 0 | 1β |
1 | 1 | 0β |
credits to Isaac Computer Science
Repo: @Day5 Blog
ping π€πΎ me on Twitter @abhayprajapati
Top comments (0)