Skip to content

Commit

Permalink
Weather app
Browse files Browse the repository at this point in the history
typing city name gets the weather of that city.
  • Loading branch information
Vinayak911dj authored Jul 9, 2024
1 parent e3bdf97 commit 116cecc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 22_WeatherApp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import requests
API_KEY = '1c9dbd438aa9277363a9b656cd0b89a4'
cityName = input('Enter the name of the City: ')
url = f'https://api.openweathermap.org/data/2.5/weather?q={cityName}&appid={API_KEY}'

response = requests.get(url)
# print(response)

if response.status_code == 200:
weather_data =response.json( )
weather_disc=weather_data['weather'] [0] ['description']
temp=weather_data['main']['temp'] -273.15
# print(weather_disc)
# Display weather info
print(f'Weather in {cityName} : {round(temp,2)} C with {weather_disc}')
else:
print(f'CityName is not found or other issues')

0 comments on commit 116cecc

Please sign in to comment.