Your question is Process Data and Verify With Tests. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
BASF quality engineers need a deterministic summary of sample viscosity readings from Ultramid® production batches. Write a Python function that groups readings by batch, calculates each batch's average viscosity, and marks the batch as PASS only when every reading is within the inclusive specification range.
The result must be easy to verify with automated tests. Return one summary per batch, sorted by batch_id.
Implement summarize_ultramid_batches(records, minimum, maximum). records is a list of dictionaries containing a string batch_id and numeric viscosity. minimum and maximum are numeric inclusive bounds. Return a list of dictionaries with the keys batch_id, count, average_viscosity, and status. Round average_viscosity to two decimal places. If any reading for a batch is outside the bounds, its status is FAIL.
def summarize_ultramid_batches(records, minimum, maximum):