This Python program leverages an API to fetch and display weather data based on user input, such as a city name.
Before using or contributing to this project, please ensure the following steps are completed:
- Python Installation: Make sure Python is installed on your system.
- Library Installation: Install the
requests
library using the commandpip install requests
. - Integrated Development Environment (IDE): It is recommended to use an IDE such as Visual Studio Code for code development.
- Import Libraries: Start by importing the
requests
library to enable HTTP requests. - URL Construction: Construct the API request URL with the provided city name and API key.
- API Request: Send a GET request to the API and store the response.
- Response Validation: Ensure the response status code is 200, indicating a successful request.
- Data Parsing: If successful, parse the JSON data from the response.
- Information Extraction: Extract relevant weather information from the JSON data.
- Error Handling: Use try-except blocks to handle potential errors during the API request process.
- User Input: Prompt the user to enter a city name.
- Function Execution: Call the
fetch_weather
function with the user-provided city name. - Display Results: If weather data is successfully retrieved, display the weather information.
- Script Execution: Ensure the main function is called when the script is executed directly.
[Ernest](tel:+234810154 0593)
This project is open-sourced under the MIT license.
For any inquiries or contributions, please contact Ugwoke Levi, Ernest, Noah.