# Simulate waiting for a process
print("Waiting for 2 seconds...")
time.sleep(2) # Pause for 2 seconds
# Test the buggy function
try:
print("Result of buggy_function(0):", buggy_function(0)) # This should fail
except Exception as e:
# Catch and print the error
print("Caught an error in buggy_function:", e)
print("Program finished!")
this is. test
adding markdown code blocks
# Sample Python script with comments for bug testing
# Import standard library
import time
# Define a simple function that adds two numbers
def add_numbers(a, b):
# This line actually performs the addition
return a + b
# Define a function that simulates a bug (division by zero error)
def buggy_function(x):
# Intentionally risky code: if x is 0, this will crash
return 10 / x
# Main program flow
if __name__ == "__main__":
# Test the add_numbers function
print("Adding 2 + 3 =", add_numbers(2, 3)) # Expect 5
# Simulate waiting for a process
print("Waiting for 2 seconds...")
time.sleep(2) # Pause for 2 seconds
# Test the buggy function
try:
print("Result of buggy_function(0):", buggy_function(0)) # This should fail
except Exception as e:
# Catch and print the error
print("Caught an error in buggy_function:", e)
print("Program finished!")