#!/usr/bin/env python3 # https://docs.python.org/3/tutorial/errors.html#handling-exceptions def garden_operation(operation_number): if operation_number == 0: int("abc") elif operation_number == 1: 10 / 0 elif operation_number == 2: open("/file.txt") elif operation_number == 3: "string" + 3 else: print("Operation completed successfully") def test_error_types(): print("=== Garden Type Demo ===") for i in range(5): try: print(f"Testing operation {i} ...") garden_operation(i) except ValueError as err: print("Caught ValueError", err) except ZeroDivisionError as err: print("Caught ZeroDivisionError:", err) except FileNotFoundError as err: print("Caught FileNotFoundError:", err) except TypeError as err: print("Caught TypeError:", err) print() return print("All error types tested successfully!") if __name__ == "__main__": test_error_types()