1
0
forked from tdwojak/Python2017
Python2017/labs03/task04.py
2017-12-15 17:50:29 +01:00

21 lines
752 B
Python

#pip install --user weather-api
from datetime import datetime
from weather import Weather
weather=Weather()
city="Poznan"
weather_city=weather.lookup_by_location(city)
print("Aktualna pogoda in "+city+" :", weather_city.condition().text())
def ftoC(t):
return round(5/9 * (t-32),3)
daymap={0:"Poniedziałek",1:"Wtorek",2:"Środa",3:"Czwartek",4:"Piątek",5:"Sobota",6:"Niedziela"}
tmin=[]
dates=[]
for item in weather_city.forecast():
dates.append(item.date())
tmin.append(ftoC(int(item.low())))
print("Minimana temperatura w dniach "+dates[0]+" - " + dates[-1]+ " to " + str(min(tmin)) +"C przewidywana na dzień "+ dates[tmin.index(min(tmin))] + " ("+daymap[datetime.strptime(dates[tmin.index(min(tmin))],'%d %b %Y').weekday()]+").")