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

Tip: Once you've imported the JSON into a variable, check the timezone's name to make sure it seems like it got the right part of the world! Tip 2: How is north vs. south and east vs. west latitude/longitude represented? Is it the normal North/South/East/West? Graded = 6/7


In [35]:
#api KEY =  c9d64e80aa02ca113562a075e57256d7

https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/10.4806,66.9036


  File "<ipython-input-35-35b532075d20>", line 4
    https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/10.4806,66.9036
         ^
SyntaxError: invalid syntax

In [36]:
import requests
response = requests.get("https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/10.4806,66.9036")
forecast = response.json()
print(forecast.keys())


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-36-aad5a9efaaf2> in <module>()
----> 1 import requests
      2 response = requests.get("https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/10.4806,66.9036")
      3 forecast = response.json()
      4 print(forecast.keys())

ImportError: No module named 'requests'

In [5]:
print(forecast['timezone'])


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-7e7f42a3506b> in <module>()
----> 1 print(forecast['timezone'])

NameError: name 'forecast' is not defined

In [7]:
print(forecast['latitude'],forecast['longitude'] )


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-7-fb94df6ab267> in <module>()
----> 1 print(forecast['latitude'],forecast['longitude'] )

NameError: name 'forecast' is not defined

2) What's the current wind speed? How much warmer does it feel than it actually is?


In [8]:
print(forecast['currently'])


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-f37a27b107e6> in <module>()
----> 1 print(forecast['currently'])

NameError: name 'forecast' is not defined

In [9]:
print("The current wind speed is", forecast['currently']['windSpeed'], "miles per hour")


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-9-9cce1a33b670> in <module>()
----> 1 print("The current wind speed is", forecast['currently']['windSpeed'], "miles per hour")

NameError: name 'forecast' is not defined

In [10]:
print("Right know in Caracas the temperature feels like",forecast['currently']['apparentTemperature'])


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-10-3c3e129cab28> in <module>()
----> 1 print("Right know in Caracas the temperature feels like",forecast['currently']['apparentTemperature'])

NameError: name 'forecast' is not defined

In [11]:
print("Right know in Caracas the temperature is",forecast['currently']['temperature'])


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-11-1fa925ddc6d8> in <module>()
----> 1 print("Right know in Caracas the temperature is",forecast['currently']['temperature'])

NameError: name 'forecast' is not defined

In [12]:
print("It feels about", forecast['currently']['apparentTemperature']-forecast['currently']['temperature'], "degrees warmer than the actual temperature")


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-12-8819f0d7a388> in <module>()
----> 1 print("It feels", forecast['currently']['apparentTemperature']-forecast['currently']['temperature'], "degrees warmer than the actual temperature")

NameError: name 'forecast' is not defined

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?


In [13]:
print(forecast['daily'].keys())


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-13-3b9c4ae6195d> in <module>()
----> 1 print(forecast['daily'].keys())

NameError: name 'forecast' is not defined

In [14]:
forecast['daily']['data']


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-14-92871f4078bb> in <module>()
----> 1 forecast['daily']['data']

NameError: name 'forecast' is not defined

In [15]:
print(type(forecast['daily']['data']))
print(forecast['daily']['data'][0])


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-15-bf03f01b3dfd> in <module>()
----> 1 print(type(forecast['daily']['data']))
      2 print(forecast['daily']['data'][0])

NameError: name 'forecast' is not defined

In [16]:
first_daily_forecast = forecast['daily']['data']


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-16-e1f1d0b2b280> in <module>()
----> 1 first_daily_forecast = forecast['daily']['data']

NameError: name 'forecast' is not defined

In [17]:
for item in first_daily_forecast[:1]: 
    print("In the first daily forecast", item['moonPhase'], "of the moon is currently visible")


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-17-ef59c1cf746b> in <module>()
----> 1 for item in first_daily_forecast[:1]:
      2     print("In the first daily forecast", item['moonPhase'], "of the moon is currently visible")

NameError: name 'first_daily_forecast' is not defined

4) What's the difference between the high and low temperatures for today?


In [19]:
for item in first_daily_forecast[:1]:
    print("The min temperature for the day is:", item['temperatureMin'], "degrees Fahrenheit")
    print("The max temperature for the day is:", item['temperatureMax'], "degrees Fahrenheit")
    print("The difference between min and max temperatures is", item['temperatureMax']-item['temperatureMin'],"degrees Fahrenheit" )


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-19-3f20bf0d206a> in <module>()
----> 1 for item in first_daily_forecast[:1]:
      2     print("The min temperature for the day is:", item['temperatureMin'], "degrees Fahrenheit")
      3     print("The max temperature for the day is:", item['temperatureMax'], "degrees Fahrenheit")
      4     print("The difference between min and max temperatures is", item['temperatureMax']-item['temperatureMin'],"degrees Fahrenheit" )

NameError: name 'first_daily_forecast' is not defined

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.


In [20]:
for item in first_daily_forecast:
    if item['temperatureMax'] > 80:
        print("The high temperature for today is", item['temperatureMax'],"degrees Farenheit" )
        print("It is going to be hot.")
    else:
        print("The high temperature for today is", item['temperatureMax'],"degrees Farenheit" )
        print("It won't be as hot as it normally is, luckily.")


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-20-9a22d84afd21> in <module>()
----> 1 for item in first_daily_forecast:
      2     if item['temperatureMax'] > 80:
      3         print("The high temperature for today is", item['temperatureMax'],"degrees Farenheit" )
      4         print("It is going to be hot.")
      5     else:

NameError: name 'first_daily_forecast' is not defined

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.


In [21]:
import requests
response = requests.get("https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/25.7742700,-80.1936600")
miami_forecast = response.json()
print(forecast_miami.keys())


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-21-646a9e86debb> in <module>()
----> 1 import requests
      2 response = requests.get("https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/25.7742700,-80.1936600")
      3 miami_forecast = response.json()
      4 print(forecast_miami.keys())

ImportError: No module named 'requests'

In [22]:
print(type(miami_forecast['hourly']))
print(miami_forecast['hourly'].keys())
print(miami_forecast['hourly']['data'][0])

miami_forecast_today = miami_forecast['hourly']['data']


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-22-ce01aa82ea83> in <module>()
----> 1 print(type(miami_forecast['hourly']))
      2 print(miami_forecast['hourly'].keys())
      3 print(miami_forecast['hourly']['data'][0])
      4 
      5 miami_forecast_today = miami_forecast['hourly']['data']

NameError: name 'miami_forecast' is not defined

In [23]:
print("Here is an estimation of how the weather in Miami will look within the next few hours")
for item in forecast_miami_today:
    if item['cloudCover'] > 0.5:
        print("It will be", item['temperature'],"degrees Farenheit and overcast.")
    else:
        print("It will be", item['temperature'], "degrees Farenheit")


Here is an estimation of how the weather in Miami will look within the next few hours
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-23-c9a2ddd9903b> in <module>()
      1 print("Here is an estimation of how the weather in Miami will look within the next few hours")
----> 2 for item in forecast_miami_today:
      3     if item['cloudCover'] > 0.5:
      4         print("It will be", item['temperature'],"degrees Farenheit and overcast.")
      5     else:

NameError: name 'forecast_miami_today' is not defined

7) What was the temperature in Central Park on Christmas Day, 1980? How about 1990? 2000?


In [31]:
import requests
response = requests.get("https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/40.7829,73.9654,346550400")
forecast_1980 = response.json()
print(forecast_1980.keys())


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-31-62427c9bd77b> in <module>()
----> 1 import requests
      2 response = requests.get("https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/40.7829,73.9654,346550400")
      3 forecast_1980 = response.json()
      4 print(forecast_1980.keys())

ImportError: No module named 'requests'

In [25]:
print(1980_forecast['daily'].keys())


  File "<ipython-input-25-9d9041b3f8a8>", line 1
    print(1980_forecast['daily'].keys())
                      ^
SyntaxError: invalid syntax

In [32]:
print(forecast_1980['daily']['data'])


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-32-ae1865f400c0> in <module>()
----> 1 print(forecast_1980['daily']['data'])

NameError: name 'forecast_1980' is not defined

In [27]:
christmas_temp_1980 = forecast_1980['daily']['data']
for item in christmas_temp_1980:
    print("On Christmas Day, 1980, temperatures ranged between", item['temperatureMax'], "and", item['temperatureMin'], "degrees Farenheit at Central Park")


  File "<ipython-input-27-f8fa6ae385c9>", line 1
    christmas_temp_1980 = 1980_forecast['daily']['data']
                                      ^
SyntaxError: invalid syntax

In [28]:
import requests
response = requests.get("https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/40.7829,73.9654,662083200")
forecast_1990 = response.json()
print(forecast_1990.keys())


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-28-4a7ea0d41bd5> in <module>()
----> 1 import requests
      2 response = requests.get("https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/40.7829,73.9654,662083200")
      3 forecast_1990 = response.json()
      4 print(forecast_1990.keys())

ImportError: No module named 'requests'

In [29]:
christmas_temp_1990 = 1990_forecast['daily']['data']
for item in christmas_temp_1990:
    print("On Christmas Day, 1990, temperatures ranged between", item['temperatureMax'], "and", item['temperatureMin'], "degrees Farenheit at Central Park")


  File "<ipython-input-29-676e95c0b1c9>", line 1
    christmas_temp_1990 = 1990_forecast['daily']['data']
                                      ^
SyntaxError: invalid syntax

In [30]:
import requests
response = requests.get("https://api.forecast.io/forecast/c9d64e80aa02ca113562a075e57256d7/40.7829,73.9654,977702400")
forecast_2000 = response.json()
print(forecast_2000.keys())


  File "<ipython-input-30-c4b56e2ecf71>", line 3
    2000_forecast = response.json()
                ^
SyntaxError: invalid syntax

In [ ]:
christmas_temp_2000 = forecast_2000['daily']['data']
for item in christmas_temp_2000:
    print("On Christmas Day, 2000, temperatures ranged between", item['temperatureMax'], "and", item['temperatureMin'], "degrees Farenheit at Central Park")