Skip to the content.

Logic Gate Homework Hacks

My answers for the Homework hacks

Homework Hack: Authorization System

Task: Fill in the missing code necessary to implement a Python function that simulates a secure entry system using an AND gate.

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

    return AND(keycard, pin, voice)

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