--- /dev/null
+def check_temperature(temp_str: str) -> None:
+ try:
+ temp = int(temp_str)
+ if temp < 0:
+ print(f"Error: {temp}°C is to cold for plants (min 0°C)")
+ elif temp > 40:
+ print(f"Error: {temp}°C is to hot for plants (max 40°C)")
+ else:
+ print(f"Temperature {temp}°C is perfect for plants!")
+ except ValueError:
+ print(f"Error: '{temp_str}' is not a valid number")
+
+
+def test_temperature_input() -> None:
+ def test_check(s: str):
+ print(f"Testing temperature: {s}")
+ check_temperature(s)
+ print()
+
+ print("=== Garden Temperature Checker ===\n")
+ test_check("25")
+ test_check("abc")
+ test_check("100")
+ test_check("-50")
+ print("All test completed - program didn't crash!")
+
+
+if __name__ == "__main__":
+ test_temperature_input()
--- /dev/null
+def garden_operations(exception: str):
+ if exception == "ValueError":
+ int("abc")
+ if exception == "ZeroDivisionError":
+ print(10 / 0)
+ if exception == "FileNotFoundError":
+ open("/dev/agilliar")
+ if exception == "KeyError":
+ {}["agilliar"]
+ print("[WARNING] No exception was raised")
+
+
+def test_error_types() -> None:
+ print("=== Garden Error Type Demo ===")
+ for error in [
+ "ValueError",
+ "ZeroDivisionError",
+ "FileNotFoundError",
+ "KeyError",
+ ]:
+ print(f"\nTesting {error}...")
+ try:
+ garden_operations(error)
+ except (
+ ValueError,
+ ZeroDivisionError,
+ FileNotFoundError,
+ KeyError,
+ ) as e:
+ print(f"Caught {type(e).__name__}: {e}")
+ print("\nAll error types tested successfully!")
+
+
+if __name__ == "__main__":
+ test_error_types()
--- /dev/null
+class GardenError(Exception):
+ def __str__(self) -> str:
+ return f"General Garden Error: {super().__str__()}"
+
+
+class PlantError(GardenError):
+ plant: str
+
+ def __init__(self, plant: str) -> None:
+ self.plant = plant
+
+ def __str__(self) -> str:
+ return f"The {self.plant} plant is wilting!"
+
+
+class WaterError(GardenError):
+ def __init__(self):
+ pass
+
+ def __str__(self) -> str:
+ return "Not enough water in the tank!"
+
+
+if __name__ == "__main__":
+ raise GardenError(12)
--- /dev/null
+[tool.black]
+line-length = 79