WEATHER PREDICTION APPLICATION
1
INDEX
[Link] TOPIC PG NO
1. INTRODUCTION 03
2. ACKNOLEDGEMENT 04
3. KEY FEATURES IN WEATHER PREDICTION 05
4. FEATURES OF PYTHON 06
5. HARDWARE AND SOFTWARE REQUIREMENT 07
6. FLOW CHART 08
7. PROGRAM 09
8. OUTPUT 14
9. CONCLUSION 15
10. BIBLIOGRAPHY 16
2
INTRODUCTION
A Weather Prediction Application is a Python-based software that
allows users to predict or retrieve weather information for a given
location. It uses various APIs or machine learning models to gather
data from weather stations and meteorological services. The core aim
of such an application is to provide real-time weather forecasts,
predictions, and updates, which may include temperature, humidity,
wind speed, precipitation, and other atmospheric parameters.
This type of project is highly beneficial for improving the user’s
understanding of weather patterns and can be extended to predict
future weather conditions based on historical data
Weather forecasting is the application of science and technology to
predict the conditions of the atmosphere for a given location and time.
People have attempted to predict the weather informally
for millennia and formally since the 19th century.
Weather forecasts are made by collecting quantitative data about the
current state of the atmosphere, land, and ocean and
using meteorology to project how the atmosphere will change at a
given place. Once calculated manually based mainly upon changes
in barometric pressure, current weather conditions, and sky conditions
or cloud cover, weather forecasting now relies on computer-based
models that take many atmospheric factors into account.
3
ACKNOWLEDGEMENT
4
FEATURES IN WEATHER FORECASTING
Here are some features of a weather prediction application built with
python are:
1. Current Weather: Displays current weather conditions,
including temperature, humidity, wind speed, and more.
2. Forecast: Provides forecasted weather conditions for the next
3-10 days, including high and low temperatures, precipitation,
and more.
3. Location Support: Allows users to search for and view
weather conditions for multiple locations worldwide.
4. Weather Alerts: Sends notifications and alerts for severe
weather conditions, such as thunderstorms, hurricanes, and
more.
Advanced Features
1. Hourly Forecast: Provides hourly forecasted weather
conditions for the next 24-48 hours.
2. Weather Radar: Displays animated weather radar imagery,
showing precipitation and other weather phenomena.
3. Weather Maps: Displays interactive weather maps, showing
current weather conditions, forecasted weather, and more.
4. Air Quality Index: Displays current air quality conditions,
including pollutant levels and health advisories.
User Interface Features
1. Interactive Dashboard: Provides an interactive dashboard for
users to view and explore weather data.
2. Customizable Units: Allows users to customize units of
measurement, such as Celsius or Fahrenheit.
5
FEATURES OF PYTHON
Python is a object oriented high level programming
language which was developed by Guido van Rossum
in 1991
Easy to use
Cross platform
Interpreted language
Standard library
Dynamic language
Extensible language
Database connectivity
Multi paradigm
Guide development
Open source language
Embeddable
6
HARDWARE AND SOFTWARE REQUIREMENT
HARDWARE REQUIREMENTS
1. Processor: Intel Core i5 or i7 processor (or equivalent)
2. Memory: 8 GB or 16 GB RAM
3. Storage: 256 GB or 512 GB SSD (solid-state drive)
4. Graphics Card: NVIDIA GeForce or AMD Radeon graphics
card (optional)
5. Internet Connection: High-speed internet connection (at least
100 Mbps)
SOFTWARE REQUIREMENTS
1. Operating System: Windows 10 or macOS High Sierra (or
later)
2. Programming Language: Python 3.8 or later (with necessary
libraries and frameworks)
3. Development Environment: PyCharm, Visual Studio Code, or
Spyder
4. Database Management System: MySQL, PostgreSQL, or
MongoDB
5. APIs and Libraries: Open Weather Map API, Dark Sky API,
or other weather APIs; NumPy, Pandas, and Matplotlib libraries
6. Machine Learning Frameworks: TensorFlow, Keras, or scikit-
learn
7. Data Visualization Tools: Tableau, Power BI, or [Link]
7
FLOW CHART
8
PROGRAM
import [Link]
import random
# -------------------------------
# MySQL Connection
# -------------------------------
def connect_db():
try:
conn = [Link](
host="localhost",
user="root",
password="sai123", # change this
database="WeatherDB"
)
return conn
except [Link] as e:
print("Database Connection Error:", e)
return None
# -------------------------------
# Generate Weather Data
# -------------------------------
9
def predict_weather(city):
temperature = round([Link](20, 40), 1)
humidity = [Link](50, 90)
pressure = [Link](1000, 1025)
wind_speed = round([Link](2, 10), 1)
if humidity > 80:
description = "Rainy"
elif temperature > 35:
description = "Hot"
elif wind_speed > 7:
description = "Windy"
else:
description = "Normal"
return temperature, pressure, humidity, wind_speed, description
# -------------------------------
# Store Weather Data
# -------------------------------
def store_data(conn, city, data):
cursor = [Link]()
sql = """
INSERT INTO WeatherData
10
(city_name, temperature, pressure, humidity, wind_speed,
description)
VALUES (%s, %s, %s, %s, %s, %s)
"""
[Link](sql, (city, *data))
[Link]()
[Link]()
# -------------------------------
# Fetch Latest Weather
# -------------------------------
def show_weather(conn, city):
cursor = [Link]()
sql = """
SELECT temperature, pressure, humidity, wind_speed, description,
timestamp
FROM WeatherData
WHERE city_name = %s
ORDER BY timestamp DESC
LIMIT 1
"""
[Link](sql, (city,))
result = [Link]()
[Link]()
11
if result:
print("\n🌤 Weather Prediction Result")
print("----------------------------")
print("Temperature :", result[0], "°C")
print("Pressure :", result[1], "hPa")
print("Humidity :", result[2], "%")
print("Wind Speed :", result[3], "m/s")
print("Condition :", result[4])
print("Time :", result[5])
else:
print("No data found.")
# -------------------------------
# Main Program
# -------------------------------
def main():
conn = connect_db()
if not conn:
return
city = input("Enter city name: ")
weather_data = predict_weather(city)
12
store_data(conn, city, weather_data)
show_weather(conn, city)
[Link]()
# -------------------------------
# Run Program
# -------------------------------
if __name__ == "__main__":
main()
MYSQL CONNECTIVITY:
CREATE DATABASE WeatherDB;
USE WeatherDB;
CREATE TABLE WeatherData (
id INT AUTO_INCREMENT PRIMARY KEY,
city_name VARCHAR(50),
temperature FLOAT,
pressure INT,
humidity INT,
wind_speed FLOAT,
description VARCHAR(50),
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP);
13
OUTPUT
Enter city name: New York
Weather in New York:
Temperature: 15°C
Pressure: 1015 hPa
Humidity: 72%
Wind Speed: 5.1 m/s
Description: Clear sky
Enter city name: chennai
Weather in chennai:
Temperature: 35°C
Pressure: 1013 hPa
Humidity: 75%
Wind Speed: 4 m/s
Description: Cloudy
Enter city name: Delhi
Weather in Delhi:
Temperature: 30°C
Pressure: 1015 hPa
Humidity: 68%
Wind Speed: 2.4 m/s
Description: Clear sky
14
Enter city name: Mumbai
Weather in mumbai:
Temperature: 28°C
Pressure: 1015 hPa
Humidity: 85%
Wind Speed: 6 m/s
Description: Partly cloudy
Enter city name: Kolkata
Weather in Kolkata:
Temperature: 28°C
Pressure: 1007 hPa
Humidity: 84%
Wind Speed: 6 m/s
Description: Mostly cloudy with light rain showers
15
CONCLUSION
The Weather Prediction Application successfully demonstrates the
process of collecting, storing, and retrieving weather data using a
simulated environment. By integrating Python with a MySQL
database, the project showcases how weather information for different
cities can be dynamically generated and stored for future reference.
Although the current version utilizes randomly simulated data, the
architecture is designed to be scalable and can be easily extended to
integrate real-time data from external APIs such as OpenWeatherMap
or WeatherAPI.
This project not only highlights essential concepts in software
development—such as database connectivity, data handling, and user
interaction—but also serves as a practical foundation for building
more advanced weather forecasting systems. Future improvements
could include real-time API integration, data visualization using
charts, historical trend analysis, and machine learning models for
accurate weather prediction. Overall, the application provides a solid
base for learning and expanding into real-world weather data analytics
16
BIBLIOGRAPHY
In making of the project I took references from the following sources
Class 12 computer text book
Gemini AI
[Link]
Sumita Arora
17
18