Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 20 lines (18 sloc) 1.02 KB
import requests
#I used https://openweathermap.org/appid to get a long dictionary of information
#and then figured out how to get the specific information I wanted from that
def weather(city):
url = "http://api.openweathermap.org/data/2.5/weather?q=" + city + "&appid=7f52051ced016ab262ba88b7cca3e55a"
data = requests.get(url).json() #swap "main" to "description" for more specific weather
temperature = (round(data["main"]["temp"]-273.15))
if temperature > 22:
return "The weather is currently: Hot and " + data["weather"][0]["main"]
elif temperature < 6:
return "The weather is currently: Cold and " + data["weather"][0]["main"]
else:
return "The weather is currently: " + data["weather"][0]["main"]
def temp(city):
url = "http://api.openweathermap.org/data/2.5/weather?q=" + city + "&appid=7f52051ced016ab262ba88b7cca3e55a"
data = requests.get(url).json()
temperature = (round(data["main"]["temp"]-273.15))
return "the temperature is currently: " + str(temperature) + " celsius"