0% found this document useful (0 votes)
0 views

PWP sd

The project aims to develop a weather application using Python and the OpenWeatherMap API, enabling users to check current weather by city name through a GUI. Students will learn API integration, HTTP requests, JSON parsing, and GUI development with Tkinter, while enhancing their Python skills. Future enhancements may include 5-day forecasts, graphical visualizations, and AI-based predictions for a comprehensive weather monitoring system.

Uploaded by

computerdept109
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)
0 views

PWP sd

The project aims to develop a weather application using Python and the OpenWeatherMap API, enabling users to check current weather by city name through a GUI. Students will learn API integration, HTTP requests, JSON parsing, and GUI development with Tkinter, while enhancing their Python skills. Future enhancements may include 5-day forecasts, graphical visualizations, and AI-based predictions for a comprehensive weather monitoring system.

Uploaded by

computerdept109
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
You are on page 1/ 5

1.

Aim:
The aim of this project is to develop a weather application using Python and
the OpenWeatherMap API, allowing users to check the current weather of any
city by entering its name. The project demonstrates how to fetch real-time
weather data and display it in a graphical user interface (GUI).
2. Course Outcomes:
By completing this project, students will:
• Learn how to fetch real-time data using APIs.
• Understand HTTP requests and JSON data parsing.
• Implement GUI development using Tkinter.
• Enhance their Python programming skills.
• Gain knowledge of event-driven programming and API integration.
• Learn how to handle API authentication using API keys.
• Improve error handling and debugging in real-time applications.
3. Proposed Methodology:
1. Register and obtain an API key from OpenWeatherMap.
2. Design a user-friendly GUI using Tkinter.
3. Make API calls to fetch weather data for a given city.
4. Parse JSON responses to extract relevant weather information.
5. Display the weather details (temperature, humidity, weather description,
wind speed, etc.).
6. Implement error handling for invalid city names or API failures.
7. Enhance UI/UX with improved layouts, fonts, and themes.
8. Integrate additional features like a 5-day weather forecast, unit
conversion (°C to °F), and weather icons.
9. Test the application with various city names and network conditions.
4. Literature Review:
• Application Programming Interfaces (APIs) – Understanding how to
interact with external data sources.
• HTTP Requests in Python – Using the requests module to fetch data
from APIs.
• JSON Parsing – Extracting structured information from API responses.
• Graphical User Interfaces (GUI) in Python – Building interactive
applications with Tkinter.
• OpenWeatherMap API – A widely used API for weather forecasting and
real-time weather updates.
• Data Visualization – Displaying weather data in a structured format.
• Security Considerations – Safeguarding API keys and handling API rate
limits.
5. Source Code:
import requests
import tkinter as tk
from tkinter import messagebox

# OpenWeatherMap API Key (Replace with your own API key)


API_KEY = "your_api_key_here"
BASE_URL = "http://api.openweathermap.org/data/2.5/weather?"

def get_weather():
city = city_entry.get()
if not city:
messagebox.showerror("Error", "Please enter a city name!")
return

url = f"{BASE_URL}q={city}&appid={API_KEY}&units=metric"
response = requests.get(url)

if response.status_code == 200:
data = response.json()
city_name = data['name']
temp = data['main']['temp']
weather_desc = data['weather'][0]['description']
humidity = data['main']['humidity']
wind_speed = data['wind']['speed']
result_label.config(text=f"City: {city_name}\nTemperature:
{temp}°C\nWeather: {weather_desc}\nHumidity: {humidity}%\nWind Speed:
{wind_speed} m/s")
else:
messagebox.showerror("Error", "City not found! Please check the name
and try again.")

# GUI Setup
root = tk.Tk()
root.title("Weather App")
root.geometry("400x300")

tk.Label(root, text="Enter City Name:", font=("Arial", 12)).pack(pady=5)


city_entry = tk.Entry(root, font=("Arial", 12))
city_entry.pack(pady=5)

tk.Button(root, text="Get Weather", command=get_weather, font=("Arial",


12)).pack(pady=10)
result_label = tk.Label(root, text="", font=("Arial", 12))
result_label.pack(pady=10)

root.mainloop()
6. Output Screenshots:
• Welcome Screen: User enters the city name.
• Weather Data Display: Shows temperature, humidity, wind speed, and
weather description.
• Error Message: Displayed when an invalid city name is entered.
• Extended Features: Future versions can include a weather icon display,
unit conversions, and 5-day forecasts.
7. Skills Developed:
• API integration using requests module.
• GUI development with Tkinter.
• Error handling for API responses.
• JSON data parsing and manipulation.
• Understanding real-time data retrieval.
• Improving problem-solving and debugging skills.
• Security awareness regarding API authentication and handling API keys
securely.
• Implementing unit conversion logic (Celsius to Fahrenheit).
• Data presentation skills using structured layouts and labels.
8. Applications:
• Used in weather forecasting applications.
• Helps users get real-time weather updates.
• Can be integrated into travel planning apps.
• Useful for smart home automation (e.g., adjusting thermostats based on
weather conditions).
• Can be extended with forecasting, maps, and alerts.
• Personalized Weather Dashboard for customized reports based on user
location.
• Disaster Management Systems to track extreme weather conditions.
9. Conclusion:
This project successfully demonstrates how Python can be used to retrieve real-
time weather data from an external API and present it in a user-friendly GUI.
The application provides instant weather updates and can be further improved
by adding 5-day forecasts, graphical visualizations, and voice-based
interaction for an advanced weather-tracking experience. Future enhancements
can include geo-location tracking, multiple city comparisons, and AI-based
weather predictions for a comprehensive weather monitoring system.

You might also like