

Weather Window
A forecast feed sends a list of dictionaries such as {"temp": 20, "condition": "rainy"}. Write analyze_weather(forecasts) that returns a summary dictionary with three keys:
avg_temp: the average temperature, rounded to one decimal placeconditions: each condition once, in the order it first appearswarmest: the condition on the warmest day (the first one if there is a tie)
An empty feed returns {"avg_temp": 0, "conditions": [], "warmest": None}.
Examples
analyze_weather([{'temp': 20, 'condition': 'rainy'}, {'temp': 24, 'condition': 'cloudy'}, {'temp': 22, 'condition': 'rainy'}])
→ {'avg_temp': 22, 'conditions': ['rainy', 'cloudy'], 'warmest': 'cloudy'}
analyze_weather([])
→ {'avg_temp': 0, 'conditions': [], 'warmest': None}
project.py
PYTHON
Saved as you type
Tests
0 of 4 passing- •three daysanalyze_weather([{'temp': 20, 'condition': 'rainy'}, {'temp': 24, 'condition': 'cloudy'}, {'temp': 22, 'condition': 'rainy'}])expected {'avg_temp': 22, 'conditions': ['rainy', 'cloudy'], 'warmest': 'cloudy'}
- •empty feedanalyze_weather([])expected {'avg_temp': 0, 'conditions': [], 'warmest': None}
- •average rounds to one placeanalyze_weather([{'temp': 10, 'condition': 'fog'}, {'temp': 11, 'condition': 'fog'}, {'temp': 11, 'condition': 'sun'}])expected {'avg_temp': 10.7, 'conditions': ['fog', 'sun'], 'warmest': 'fog'}
- •single dayanalyze_weather([{'temp': -3, 'condition': 'snow'}])expected {'avg_temp': -3, 'conditions': ['snow'], 'warmest': 'snow'}
On the line
+340 XP
Pass all 4 tests to claim it.
