Industrial Programming (Python) - Case Study 2 - Puviyarasu A
Industrial Programming (Python) - Case Study 2 - Puviyarasu A
Choices of the UI design are up to you, but a good UI design with good amount of details and
familiar look and feel is expected. Do not use others’ projects, and do not use libraries other
than json and urllib to perform the tasks.
Part I: OpenWeather.
Key Features:
- Real-Time Weather Data: Provides live weather data for cities worldwide. (Covers data
from over 200,000 cities)
- Forecasting: Provides daily and hourly forecasts.
- Customizable Metrics: Supports both metric and imperial units.
- API Integration: APIs use REST architecture and JSON for data representation, making
them easy to integrate into applications.
To access OpenWeather's services, developers need to sign up for an account and generate an
API key. The unique key generated is then used to authenticate requests.
Part II: Code
#Importing Libraries for API functionality
import json
import urllib.request
try:
# Fetching and parsing the JSON data
with urllib.request.urlopen(url) as response:
data = json.load(response)
Explanation:
We retrieve real-time weather data for the user-specified city using the OpenWeather API. This
data includes temperature, "feels like" temperature, minimum and maximum temperatures, and a
description of the city’s current weather condition (e.g., cloudy, sunny). This information is
displayed on a clean and interactive GUI built using Python's tkinter GUI library.
1. Importing Libraries
● json: Parses the JSON data received from the API.
● urllib.request: Handles the HTTP request to fetch data from the OpenWeather API.
● tkinter: A Python library to create the graphical interface with widgets like labels,
buttons, and entry fields.