Weather Forecast App
This document contains a Python script for 'Weather Forecast App'.
It includes an overview, usage instructions, and the full source code.
### Overview:
This script implements 'Weather Forecast App', which helps users with weather forecast
app.
### How to Use:
1. Run the script in a Python environment.
2. Follow the on-screen prompts to interact with the program.
3. The script performs its function based on user input.
4. Modify the script as needed to add more features.
import requests
API_KEY = "your_api_key_here" # Replace with a valid API key
BASE_URL = "http://api.openweathermap.org/data/2.5/weather"
def get_weather(city):
url = f"{BASE_URL}?q={city}&appid={API_KEY}&units=metric"
response = requests.get(url)
data = response.json()
if response.status_code == 200:
print(f"Weather in {city}: {data['weather'][0]['description']}")
print(f"Temperature: {data['main']['temp']}C")
else:
print("City not found.")
if __name__ == "__main__":
city = input("Enter city name: ")
get_weather(city)
Additional Notes / Customization Ideas:
--------------------------------------------------
Additional Notes / Customization Ideas:
--------------------------------------------------
Additional Notes / Customization Ideas:
--------------------------------------------------