DEV Community

Astghik
Astghik

Posted on

Logic Gates with the students of Intro to CS, section A.

Hello, little and big explorers ! Today, we are going to learn about Logic Gates through real examples. If you do not have an idea what real examples are, you can come to our Intro to CS class, and you will have a deeper understanding of that; if you are too lazy to do so, I am going to discuss some of them in this blog post. 314W is the classroom where these real examples come true.

What Are Logic Gates?

Logic gates are fun ways to think about the thing by using only 1s and 0s. In his blog post, you are getting to know 3 of them: AND, OR, and XOR.

AND Gate: The AND gate outputs true, which we will call (1) only when all its inputs are true. 
 
1 AND 1 = 1
1 AND 0 = 0
0 AND 1 = 0
0 AND 0 = 0

 
Example: AND
How do we know if our professor, Mr. Khachatur, or a student in our section will be late by using the AND gate?

First thing: traffic (A=1).
Second Thing: class starting soon(B = 1)

So we say :

If A AND B are true (1 AND 1=1), they will be late
If both are true, they will be late.
If both are false, they will not be late.

OR Gate: The OR gate outputs true (1) if at least one of its inputs is true. It outputs false (0) when all inputs are false.

0 OR 0 = 0 
0 OR 1 = 1 
1 OR 0 = 1
1 OR 1 = 1 

Example: OR 
How do you be aware of new homework?

First Way:  Mr. Khachatur put it on Moodle.
Second Way: Your friend said you have 

So we say :
IF A OR B is true (A OR B = 1), you know you have homework! 
If both are true, you have homework.
If both are false, you do not have homework.

XOR Gate: The XOR gate outputs true (1) only when an odd number of its inputs are true. For two inputs, the output is true if exactly one input is true.

0 XOR 0 = 0
0 XOR 1 = 1 
1 XOR 0 = 1
1 XOR 1 = 0

Example: XOR 
How to use XOR gate to know if we will have a quiz today

First Way:  Mr. Khachatur announced to us
Second Way: We are done with that day’s material and logical problems, but we have an extra twenty or fifteen minutes.

So we say: 

IF exactly one of these is true( A is true, B is false, or A is false, B is false), then we will have a quiz! (I know that partially this is not realistic, since if we do not have time, how we will have a quiz, but XOR gate works this way)

If both are true, we will not have a quiz (this is not realistic, too, but XOR gate works this way.)

If both are false, we will not have a quiz(not realistic too)

So this was today’s topic; thanks for reading.

See you soon!

Best Regards,
Astghik Harutyunyan

Top comments (0)