0% found this document useful (0 votes)
32 views5 pages

Weather Forecast

The document provides a Python script for a 'Weather Forecast App' that allows users to obtain weather forecasts. It includes an overview, usage instructions, and the full source code, which utilizes the OpenWeatherMap API. Users can run the script, input a city name, and receive weather information, with options for further customization.

Uploaded by

Aayush Karn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views5 pages

Weather Forecast

The document provides a Python script for a 'Weather Forecast App' that allows users to obtain weather forecasts. It includes an overview, usage instructions, and the full source code, which utilizes the OpenWeatherMap API. Users can run the script, input a city name, and receive weather information, with options for further customization.

Uploaded by

Aayush Karn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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:
--------------------------------------------------

You might also like