# coding=utf-8 """ **ćwiczenie 4** Zainstaluj bibliotekę ``weather-api`` (https://pypi.python.org/pypi/weather-api). Korzystając z niej: * Wypisz informacje o aktualnej pogodzie. * Napisz funkcję, która zamieni stopnie ``F`` na ``C``. * Korzystając z prognozy, znajdź dzień, w którym będzie najzimniej. Wypisz nazwę tygodnia (w języku polskim) i temperaturę w C. """ from weather import Weather from operator import itemgetter from datetime import datetime def FhCs(x): x = float(x) cs = (x - 32)/1.8 return round(cs, 1) userInput = raw_input('Please type a city name: ') weather = Weather() city = weather.lookup_by_location(userInput) cityNow = city.condition() cityNowText = cityNow.text() cityNowTemp = cityNow.temp() cityCelsius = FhCs(cityNowTemp) print 'Current weather: ', cityNowText, ', ', cityCelsius, '°C' cityForecasts = city.forecast() x = {forecast.date() : forecast.low() for forecast in cityForecasts} y = min(x.iteritems(), key=itemgetter(1)) date = datetime.strptime(y[0], "%d %b %Y") minCels = FhCs(y[1]) print date.strftime("%A"), minCels