a = int(input("Enter a number: "))
b = int(input("Enter another number: "))
if a > b:
    print("first is bigger")
elif a < b:
    print("second is bigger")
else:
    print("they are equal")
second is bigger

Hack 2

sunny = input("Enter a string: ")
weekend = input("Enter another string: ")

if sunny and weekend == "true":
    print("Its a good day")
elif sunny or weekend == "true":
    print("Its not a good day")
Its a good day

Hack Optional

a = input("Enter True/False: ")
b = input("Enter True/False: ")

if(a or b):
    print("Its a good day")
else:
    print("Its not a good day")
Its a good day

Hack 3

a = False
b = True


if not a:
    print("a is false") ## not a is true, not means opposite
elif a and b:
    print("a and b are true") ## and means both
elif a or b:
    print("a or b is true") ## or means either
a is false

Hack 4

## light switches using xor
light_downstairs = int(input("Enter 0 or 1: "))
light_upstairs = int(input("Enter 0 or 1: "))

if light_downstairs ^ light_upstairs:
    print("The lights are on")
else:
    print("The lights are off")
The lights are on

Hack 5 Optional

A = False
B = False

if not (A or B):
    print("It's true!")
else:
    print("It's false!")

It's true!

Homework Section

def xnor_gate(a, b):
    if (a and b) or (not a and not b):
        return 1
    else:
        return 0

# Test cases
input_values = [(0, 0), (0, 1), (1, 0), (1, 1)]

for a, b in input_values:
    result = xnor_gate(a, b)
    print(f"XNOR({a}, {b}) = {result}")

XNOR(0, 0) = 1
XNOR(0, 1) = 0
XNOR(1, 0) = 0
XNOR(1, 1) = 1
# Define logic gates functions
def and_gate(a, b):
    return a and b

def or_gate(a, b):
    return a or b

def xor_gate(a, b):
    return (a and not b) or (not a and b)

# Interactive program
print("Logic Gate Simulator")
while True:
    print("\nChoose a logic gate to simulate:")
    print("1. AND Gate")
    print("2. OR Gate")
    print("3. XOR Gate")

    choice = input("Enter your choice (1/2/3): ")

    if choice == '1':
        a = bool(int(input("Enter input A (0 or 1): ")))
        b = bool(int(input("Enter input B (0 or 1): ")))
        result = and_gate(a, b)
        print(f"AND Gate result: {int(result)}")
        break

    elif choice == '2':
        a = bool(int(input("Enter input A (0 or 1): ")))
        b = bool(int(input("Enter input B (0 or 1): ")))
        result = or_gate(a, b)
        print(f"OR Gate result: {int(result)}")
        break

    elif choice == '3':
        a = bool(int(input("Enter input A (0 or 1): ")))
        b = bool(int(input("Enter input B (0 or 1): ")))
        result = xor_gate(a, b)
        print(f"XOR Gate result: {int(result)}")
        break

    else:
        print("Invalid choice. Please select 1, 2, 3, or 4.")

Logic Gate Simulator

Choose a logic gate to simulate:
1. AND Gate
2. OR Gate
3. XOR Gate
AND Gate result: 0
def mark_homework(completed, on_time):
    problem_incomplete = not completed
    not_on_time = not on_time
    incomplete = problem_incomplete or not_on_time
    return "Incomplete" if incomplete else "Complete"

# Initialize a list of students with their completion and submission status
students = [
    {"name": "Alice", "completed": True, "on_time": True},
    {"name": "James", "completed": False, "on_time": True},
    {"name": "Charlie", "completed": True, "on_time": False},
    {"name": "David", "completed": False, "on_time": False},
]

# Create a dictionary to store the grades for each student
grades = {}

# Grade each student's homework
for student in students:
    name = student["name"]
    completed = student["completed"]
    on_time = student["on_time"]
    result = mark_homework(completed, on_time)
    grades[name] = result

# Print the grades
for name, grade in grades.items():
    print(f"{name}'s Homework Status: {grade}")

Alice's Homework Status: Complete
James's Homework Status: Incomplete
Charlie's Homework Status: Incomplete
David's Homework Status: Incomplete