AI Agents by HandAll problemsAbout

All problems › Python drill · easy · ~4 min

d12 · Describe temperatures with gaps

None vs 0

Solve it in your browser →

d12 · Describe temperatures with gaps (~4 min)

Numbers, missing values, time. Edit drills.py. Standard library only; no model calls, no API key.

def describe_temps(temps, cities):

temps maps lowercase city names to a float temperature in °C, or None when there's no data.

For each requested city (any case, maybe padded with spaces), in order, return: "Tokyo: 18.0°C" when there's a reading (0.0 is a real temperature), "Tokyo: no data" when the value is None, "Tokyo: unknown city" when the city isn't in temps. The city is shown stripped and in title case.

Failure messages are enough to go on, so leave the tests unread until you submit.

Starter code and hidden tests open in the editor. Nothing to install.