• Weather Api Example

    #!/usr/bin/env python ### PLEASE EXECUTE IT ON YOUR LOCAL ENV import json, sys, urllib # Input Values location = raw_input("Please Enter a valid City..") base_uri = "http://api.openweathermap.org/data/2.5/weather?q=%s" % (location) key = 'f1a52e0d2011b0b4f042744e05ce2498' url = base_uri + '&APPID=' + key api_response = urllib.urlopen(url) # Recieve the response and load it as json jsonRaw = api_response.read() diction = json.loads(jsonRaw) # Parse the needed information city = diction["name"] lat=diction["coord"]["lat"] lon=diction["coord"]["lon"] ctemp = float(diction["main"]["temp"]) tempmax = float(diction["main"]["temp_max"]) tempmin = float(diction["main"]["temp_min"]) # output section print("City name you selected is : " + city) print('\n') print ('-------Coordinates of %s----------') %(location) print("Latitude :\t" + str(lat)) print("Longitude :\t" + str(lon)) print('\n') print ('-------TEMPERATURE DETAILS---------') print ("Current temperature :\t" + str(ctemp) + " 'In Kelvin'") print ("Max temperature :\t" + str(tempmax) + " 'In Kelvin'") print ("Min temperature :\t" + str(tempmin) + " 'In Kelvin'") Ask Vikas
    Just press 'Run'.