question 274 Data Models & Typing · easy
Problems in a weather reading
Daily weather readings arrive as JSON objects. Write a TypedDict Reading with required station and date (text) and tmax and tmin (°C), and an optional prcp (millimetres of rain). Then write reading_problems(row) that checks a row using the TypedDict's own required keys, plus two rules: the minimum can't be above the maximum, and rainfall can't be negative.
TypedDict
Reading: station: str, date: str, tmax: float, tmin: float, prcp: NotRequired[float]Function
reading_problems(row) → a list of textsOrder
"missing <key>" for each missing required key (sorted), then "tmin above tmax" (only if both are present), then "negative prcp"