diff --git a/examples/mathkit/__init__.py b/examples/mathkit/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/examples/mathkit/operations.py b/examples/mathkit/operations.py new file mode 100644 index 00000000..8e692520 --- /dev/null +++ b/examples/mathkit/operations.py @@ -0,0 +1,27 @@ +"""Basic arithmetic operations for the mathkit example package.""" + + +def add(a: float, b: float) -> float: + """Return the sum of ``a`` and ``b``.""" + return a + b + + +def subtract(a: float, b: float) -> float: + """Return the difference of ``a`` and ``b``.""" + return a - b + + +def multiply(a: float, b: float) -> float: + """Return the product of ``a`` and ``b``.""" + return a * b + + +def divide(a: float, b: float) -> float: + """Return the quotient of ``a`` divided by ``b``. + + Raises: + ValueError: If ``b`` is zero. + """ + if b == 0: + raise ValueError("Cannot divide by zero") + return a / b