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?
Chatbot/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.
30 lines (17 sloc)
818 Bytes
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
#This whole section of code is the weather feature | |
#code copied from: https://www.youtube.com/watch?v=gOWm5rF_qdc&list=PLtN7kQKfzoJOJYt_yhn_xHWsORCMsEOXq&index=4&t=194s | |
#pwown is a module | |
#Needs to be installed first for the code to be able to run | |
import pyowm | |
#api code within the bracket was obtained from: https://openweathermap.org/ | |
own = pyowm.OWM('7050f6a47e2d8369b80ae88aafb6c357') | |
#The user inputs the name of the location | |
#The variable 'inputLoc' was created on my own | |
inputLoc = input("tell me your location: ") | |
location = own.weather_at_place(inputLoc) | |
weather = location.get_weather() | |
temp = weather.get_temperature('celsius') | |
humidity = weather.get_humidity() | |
#receive the temperature (in celcius) and humidity of chosen location | |
print(temp) | |
print(humidity) | |