Skip to content

Commit 3677988

Browse files
committed
Task_5 Weather_info completed
1 parent 13fb408 commit 3677988

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import requests
2+
3+
API_key = '01234567890'
4+
5+
def get_weather(city):
6+
url = f'http://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_key}&units=metric'
7+
res = requests.get(url).json()
8+
return res
9+
10+
11+
def main():
12+
city = input("Enter city name to fetch weather info. : ")
13+
data = get_weather(city)
14+
print(f"Weather in {city}")
15+
print(f"Temperature: {data['main']['temp']} °C")
16+
17+
18+
if __name__ == '__main__':
19+
main()

0 commit comments

Comments
 (0)