Generation

generate functionThu, 09 Feb 2023

create a python api that gets the current weather of Hargeisa

import requests from datetime import date def main(): url = 'https://api.openweathermap.org/data/2.5/weather?q=Hargeisa&appid=8a9a5a2f7f3a5a5666a66a6a66a6a665&units=metric' res = requests.get(url) data = res.json() #print(data) city = data['name'] today = date.today() temp = data['main']['temp'] humidity = data['main']['humidity'] wind_speed = data['wind']['speed'] weather_description = data['weather'][0]['description'] print('City: {}'.format(city)) print('Temperature: {}'.format(temp)) print('Humidity: {}'.format(humidity)) print('Wind speed: {}'.format(wind_speed)) print('Weather: {}'.format(weather_description)) print('Today is: {}'.

Questions about programming?Chat with your personal AI assistant