PY-19
Calculate a Score from Paired Values
Task
Write mean_absolute_error(expected, produced). It compares two lists of
numbers position by position. For each pair, find the absolute difference
abs(expected_value - produced_value). The score is the mean of all those
differences.
Return a two-item tuple (score, status):
- if the lists have different lengths, return
(None, "unequal lengths"); - if both lists are empty, return
(None, "empty"); and - otherwise, return
(mean absolute difference, "ok").
The paired values are matched by their positions; do not reorder either list. Neither input list may be changed.
Example
The absolute differences are 1, 2, and 1, so their mean is
(1 + 2 + 1) / 3, or 4 / 3. A mismatch is reported before any score is
calculated:
Your implementation
Edit solution.py and keep this function name and signature:
Return exactly the required tuple and status strings. For a non-empty pair,
score must be the arithmetic mean of the position-wise absolute differences;
there is no rounding step. Equal empty lists are the one case that returns an
"empty" status instead of a number. Do not print the result, ask for input,
or mutate either list.