A command-line tool that accepts a city's name and returns the current weather forecast. Leverage OpenWeatherMap API to fetch weather data and parse it using Python. Demonstrate how GitHub Copilot can help us with API usage, data parsing, and error handling.
- Python 3.x
- requests library
-
Clone the repository or copy the script into your local environment.
-
Install the required dependencies. Open a terminal or command prompt and run the following command:
-
Obtain an API key from OpenWeatherMap by creating an account on their website.
-
Open the script in a text editor or Python IDE.
-
Locate the following line of code: ```python API_KEY = "11d9310e526c7fb43fc68cdfbf744078"
-
Replace "11d9310e526c7fb43fc68cdfbf744078" with your actual OpenWeatherMap API key.
python weather_forecast.py
-
Enter the name of the city for which you want to retrieve the weather forecast when prompted.
-
The script will make an API request to OpenWeatherMap and display the temperature, humidity, pressure, and weather description for the specified city.
If you encounter an error in the HTTP request, ensure that you have entered a valid API key and that you have an active internet connection.
If the API request fails, double-check the city name you entered and ensure it is spelled correctly.
--------------------------------------------------------------THANK YOU-----------------------------------------------------------------------------