Skip to content

Commit baf0072

Browse files
authored
Add files via upload
1 parent 63b7818 commit baf0072

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

weather_forecast.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import requests,json
2+
#https://api.openweathermap.org/data/2.5/weather?q={city name},{state code},{country code}&appid={API key}
3+
4+
api_key="7fc81f1a385f0cda5328d0a4c1ec2659"
5+
base_url="https://api.openweathermap.org/data/2.5/weather?q="
6+
city_name=input("Enter City Name: ")
7+
state_code=input("Enter State Code: ")
8+
country_code=input("Enter Country Code: ")
9+
complete_url=base_url+city_name+","+state_code+country_code+"&appid="+api_key
10+
response=requests.get(complete_url)
11+
data=response.json()
12+
note=data["weather"]
13+
print("===============WEATHER FORECAST===============")
14+
print("City: ",city_name)
15+
print("Current Temperature: ",data["main"]["temp"])
16+
print("Current Humidity: ",data["main"]["humidity"])
17+
print("Description: ",note[0]["description"])

0 commit comments

Comments
 (0)