Skip to the content.

Logic Gates

Hacks

DevOps

Popcorn Hack 1

Q. What are methods of real-world purpose that using logic gates can implement? Explain deeper if using our listed impacts, explaining why this impact is helpful.

A. Things like automatic doors and car lights use OR gates. For the doors you can be on either side and car lights are when any door is open. Turning most modern cars on are AND gates. You have to press the brake while turning the engine on. This impact is helpful because it adds things to our lives that would otherwise be annoying. If turning on the engine did not require pressing down the brake someone might accidentally turn on their car when they didn’t mean to. And if automatic doors didn’t have OR, then they wouldn’t be very good doors.

Popcorn Hack 2

A digital circuit receives three binary inputs: X, Y, and Z. The circuit outputs 1 if and only if X AND Y are both 1, OR Z is 1.
Which of the following expressions represents the circuit’s behavior?
A. (X AND Y) OR Z B. X AND (Y OR Z) C. (X OR Y) AND Z D. NOT(X AND Y) OR Z

Answer I chose: A. (X AND Y) OR Z
This is because all of the other ones have different properties and only this one does the correct thing.

Homework

def secure_entry_system(keycard, pin, voice_auth):
    def AND(a, b):
        return a & b 

    first_check = AND(keycard, pin)
    final_check = AND(first_check, voice_auth)

    return final_check

print(secure_entry_system(1, 1, 1)) # should return 1
print(secure_entry_system(1, 1, 0)) # shoudl return 0
print(secure_entry_system(0, 1, 1)) # should return 0
print(secure_entry_system(1, 0, 1)) # should return 0

1
0
0
0