Task: Implement a small, self-contained PMT helper function
Description:
Create and implement a function constant_return_pmt in a new module loan_calculator/pmt.py. The function should compute a simple, constant per-period payment for a loan in a minimal, well-defined way that satisfies the given test case.
Requirements:
File structure:
Create package loan_calculator with an empty init.py.
Add module loan_calculator/pmt.py containing the function constant_return_pmt.
pv may be a scalar (number) or an iterable (e.g., a list/tuple) of numbers. If pv is iterable, use its first element as the principal.
Convert inputs to floats where appropriate.
Validate inputs:
nper must be > 0; otherwise raise a ValueError.
pv must contain at least one numeric value (if iterable) or be numeric (if scalar); otherwise raise a TypeError/ValueError.
Calculation (for this task’s purposes):
Compute principal = first element of pv if pv is iterable, else float(pv).
Return payment = principal / nper as a float. The function may ignore rate for this simplified variant, since the test exercises a case where this yields 1.0.
Output:
Return a float representing the per-period payment.
Documentation:
Include a concise docstring explaining the simplified semantics and the expected behavior for typical inputs.
Accessibility:
Ensure the test from the prompt imports correctly: from loan_calculator.pmt import constant_return_pmt
Acceptance criteria:
Running the provided test test_unitary_evaluation passes, i.e., constant_return_pmt(1.0, 1.0, [1, 1]) returns 1.0 (within the 0.01 tolerance).
The function handles pv as a list/tuple (e.g., [1, 1]) and as a scalar, and raises appropriate errors for invalid inputs.