-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweatherapp.py
More file actions
21 lines (17 loc) · 989 Bytes
/
weatherapp.py
File metadata and controls
21 lines (17 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import requests
apikey = 'your api key'
print(" ____ /\ _____ | | ____ _____ ")
print("\ /\ / | / \ | | | | | | ")
print(" \ / \ / |____ / \ | |______| |____ |____| ")
print(" \ / \ / | /______\ | | | | | \ ")
print(" \/ \/ |____ / \ | | | |____ | \ ")
location = input("enter loaction :")
weatherdata = requests.get(
f"https://api.openweathermap.org/data/2.5/weather?q={location}&units=imperial&APPID={apikey}")
if weatherdata.json()['cod'] =='404':
print("City not found")
else:
weather = weatherdata.json()['weather'][0]['main']
temp = round(weatherdata.json()['main']['temp'])
print("weather of" ,location, "is" ,weather )
print("Temperature of",location, "is", temp ,"degrees")