PY-26

Compare Paired Outcomes

  • Easy–Medium
  • Counts and Outcomes
  • Python

Task

Write count_outcomes(expected, produced, positive_label). The two lists have the same length. Each value is either positive_label or a different label that means negative. Compare the values at each shared position and count four outcomes:

  • true_positive: expected positive and produced positive;
  • false_positive: expected negative and produced positive;
  • false_negative: expected positive and produced negative;
  • true_negative: expected negative and produced negative.

Return one dictionary with exactly those four keys followed by total, the number of paired values. Treat any value that is not positive_label as negative. Empty lists return all zero counts and total 0. Do not mutate either input list.

Example

The two lists are aligned by position; no pairing or sorting by label is done.

Your implementation

Edit solution.py and keep this function name and signature:

Return a dictionary with exactly the five named keys and integer counts. The four outcome counts must add to total. Do not print, ask for input, or mutate either list.