Permalink
Cannot retrieve contributors at this time
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?
Impersonation-bot/weather.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
20 lines (18 sloc)
1.02 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |