Skip to the content.

Logic Gates

None

Tri 3 Team Teach Hacks

Popcorn Hacks

Popcorn Hack

Logic gates are used in real life for stuff like:

  • Traffic Lights
    Logic gates control when lights should switch to prevent crashes.

  • Alarm Systems
    OR gates can set off alarms if any sensor (like a door or motion sensor) goes off.

This is helpful because logic gates make systems smarter, safer, and automatic. They let machines make quick decisions based on different inputs.


Popcorn Hack 2

Answer: A. (X AND Y) OR Z

Explanation:
The output is 1 if X and Y are both 1 (X AND Y), or if Z is 1. So the logic is: (X AND Y) OR Z


Homework Hack

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

    step1 = AND(keycard, pin)
    return AND(step1, voice_auth)

# Test cases
print(secure_entry_system(1, 1, 1))  # Expected Output: 1 (Access Granted)
print(secure_entry_system(1, 1, 0))  # Expected Output: 0 (Access Denied)
print(secure_entry_system(0, 1, 1))  # Expected Output: 0 (Access Denied)

1
0
0