This Python script retrieves real-time weather data for any city using the OpenWeatherMap API. It provides a user-friendly interface to enter a city name and displays the current weather condition, temperature (in Fahrenheit), and humidity.
- User input for city selection
- Accesses weather data from OpenWeatherMap API
- Displays weather condition, temperature, and humidity
- Clean and formatted output
- Python 3 (Download from https://www.python.org/downloads/)
- An OpenWeatherMap API key (Free registration available at https://openweathermap.org/)
- Obtain an API Key: Sign up for a free OpenWeatherMap account and generate your API key.
- Replace Placeholder: Replace the
api_key
variable in the code with your own API key. - Run the Script: Save the script as a Python file (e.g.,
weather_app.py
) and run it from your terminal usingpython weather_app.py
. - Enter City Name: When prompted, enter the city name for which you want weather information.
enter the city name: London
the weather in London is: Clouds
the temperature in London is: 54 degrees Fahrenheit
the humidity in London is: 78 percent
Feel free to fork this repository and contribute improvements!
This could include:
- Implementing features like displaying icons for weather conditions
- Adding functionality to display forecast for multiple days
- Error handling for invalid city names or API key issues