# SEOUL = '37.532600,127.024612'
response = requests.get("https://api.forecast.io/forecast/4230d91e7452245b2479aec2fc16870d/37.532600,127.024612")
data = response.json()

data.keys()

data['timezone']

"""
Explanation: 1) Make a request from the Forecast.io API for where you were born (or lived, or want to visit!).
End of explanation
"""


# Wind speed
data['currently']['windSpeed']

# How much warmer does it feel than it actually is
data['currently']['apparentTemperature']-data['currently']['temperature']

"""
Explanation: 2) What's the current wind speed? How much warmer does it feel than it actually is?
End of explanation
"""


daily = data['daily']['data']
print (daily[0]['moonPhase'])

"""
Explanation: 3) The first daily forecast is the forecast for today. For the place you decided on up above, how much of the moon is currently visible?
End of explanation
"""


daily[0]['temperatureMax']-daily[0]['temperatureMin']

"""
Explanation: 4) What's the difference between the high and low temperatures for today?
End of explanation
"""


for temmax in daily:
    print (temmax['temperatureMax'])
    if temmax['temperatureMax'] <80:
        print ("Oh, it's cold")
    else:
        print("Oh, it's warm")

"""
Explanation: 5) Loop through the daily forecast, printing out the next week's worth of predictions. I'd like to know the high temperature for each day, and whether it's hot, warm, or cold, based on what temperatures you think are hot, warm or cold.
End of explanation
"""


# Miami, Florida = 25.787676,-80.224145
response = requests.get("https://api.forecast.io/forecast/4230d91e7452245b2479aec2fc16870d/25.787676,-80.224145")
data = response.json()

data['timezone']

hourly = data['hourly']['data']
for weather in hourly:
    if weather['cloudCover'] > 0.5:
        print (weather['temperature'],"and cloudy")
    else:
        print(weather['temperature'])

    

"""
Explanation: 6) What's the weather looking like for the rest of today in Miami, Florida? I'd like to know the temperature for every hour, and if it's going to have cloud cover of more than 0.5 say "{temperature} and cloudy" instead of just the temperature.
End of explanation
"""


# 1980-12-25 = '346550400'
# Central Park = '40.785091,-73.968285'
response = requests.get("https://api.forecast.io/forecast/4230d91e7452245b2479aec2fc16870d/40.785091,-73.968285,346550400")
data = response.json()

data['currently']['temperature']
print ("It was", data['currently']['temperature'], "degree in Central Park on Christmas Day in 1980")

# 1990-12-25 = '662083200'
response = requests.get("https://api.forecast.io/forecast/4230d91e7452245b2479aec2fc16870d/40.785091,-73.968285,662083200")
data = response.json()

print ("It was", data['currently']['temperature'], "degree in Central Park on Christmas Day in 1990")

# 2000-12-25 = '977702400'
response = requests.get("https://api.forecast.io/forecast/4230d91e7452245b2479aec2fc16870d/40.785091,-73.968285,977702400")
data = response.json()

print ("It was", data['currently']['temperature'], "degree in Central Park on Christmas Day in 2000")

"""
Explanation: 7) What was the temperature in Central Park on Christmas Day, 1980? How about 1990? 2000?
End of explanation
"""


