Sitemap
inprogrammer

inprogrammer

AI Engineer & storyteller. Translating machine learning, modern tech, and productivity into narratives worth your screen time.

Weather Forecast App Using Python

5 min readDec 31, 2025

--

Press enter or click to view image in full size

Weather Forecast App Using Python

Python is one of the most widely used programming languages today. It is simple to learn, powerful, and used in many real-life applications such as automation, web development, and data analysis. One very useful and practical project for beginners to intermediate learners is a Weather Forecast App using Python.

This project helps you understand how real applications work. In this article, we will explain how a weather forecast app can be built using Python to show live weather updates with the help of external APIs like OpenWeatherMap. This project is perfect for students, Python learners, and developers who want hands-on experience with APIs and real-time data.

Why Build a Weather Forecast App Using Python?

A weather forecast app is more than just a practice project. It helps you learn many important programming concepts together.

By building a Weather Forecast App using Python, you learn:

  • How to use third-party APIs
  • How to work with live data
  • How to read and use JSON data
  • How to create desktop or web applications
  • How to show useful information in a simple way

Because of these benefits, this project is a great addition to your resume, GitHub profile, and interview preparation.

Project Overview

The main aim of this project is to create a desktop or web application that collects live weather data and shows it clearly to users.

Application Description

The app displays real-time weather details using an external API such as OpenWeatherMap. Users can search weather information by entering a city name. The app then shows important details like temperature, wind speed, and humidity.

Key Features of the Weather Forecast App

1. City-Wise Weather Search

Users can type the name of any city to get current weather updates. The app sends the city name to the weather API and receives the latest data.

2. Temperature, Wind, and Humidity Display

The app shows important weather details such as:

  • Current temperature
  • Wind speed
  • Humidity level
  • Weather condition like sunny, cloudy, or rainy

All information is shown in a clear and easy-to-read format.

3. API Integration

API integration is the heart of this project. The app connects to the OpenWeatherMap API, receives live weather data in JSON format, and processes it using Python.

Tools and Technologies Used

To build a Weather Forecast App using Python, you usually need:

  • Python 3
  • Requests library for sending API requests
  • JSON handling
  • Tkinter for desktop apps or Flask for web apps
  • OpenWeatherMap API

You can choose to build either a desktop version or a web version based on your interest.

Understanding the OpenWeatherMap API

OpenWeatherMap is a popular weather service that provides live weather data for cities around the world.

Get inprogrammer’s stories in your inbox

Join Medium for free to get updates from this writer.

To use this API, you need:

  • A free OpenWeatherMap account
  • An API key
  • Basic knowledge of HTTP requests

Once you have the API key, you can request weather data by sending the city name as a parameter.

How the Weather Forecast App Works

The working process of the app is simple:

  1. The user enters a city name
  2. Python sends a request to the OpenWeatherMap API
  3. The API returns weather data in JSON format
  4. Python extracts temperature, humidity, and wind details
  5. The data is shown on the app screen

This step-by-step flow makes the project easy to understand and very effective.

Desktop vs Web Weather App

Desktop Weather App Using Python

If you prefer desktop applications, Tkinter is a good option. It allows you to create a simple graphical interface quickly.

Benefits:

  • No need for a web browser
  • Easy to share with others
  • Suitable for beginners

Web Weather App Using Python

For a web-based version, Flask is commonly used.

Benefits:

  • Can be opened on any device
  • Better design options
  • Good for hosting online

Both options are excellent for building a Weather Forecast App using Python.

SEO and Portfolio Value

This project has strong value for both SEO and career growth because:

  • Weather apps are commonly searched online
  • Python API projects are popular with recruiters
  • It shows real-world problem-solving skills
  • It proves frontend and backend connection

If you upload this project to GitHub and write about it on Medium, it can bring traffic, learning opportunities, and job interest.

Use Cases of a Python Weather Forecast App

  • Learning API usage
  • College mini projects
  • Resume and portfolio showcase
  • Freelance demo projects
  • Daily Python practice

Many beginners choose this project as their first real-world Python application.

Best Practices While Building the App

  • Keep your API key safe
  • Handle wrong city names properly
  • Show clear error messages for network problems
  • Keep the design simple
  • Write clean and easy-to-read Python code

Following these tips improves both the user experience and code quality.

Source Code -

import tkinter as tk
from tkinter import messagebox
import requests

def get_weather():
city = city_entry.get()

if not city:
messagebox.showwarning("Input Error", "Please enter a city name!")
return

# OpenWeatherMap API setup
api_key = "YOUR_API_KEY_HERE" # <--- PASTE YOUR KEY HERE
base_url = "http://api.openweathermap.org/data/2.5/weather"

# Parameters for the API call (units='metric' gives Celsius)
params = {
'q': city,
'appid': api_key,
'units': 'metric'
}

try:
response = requests.get(base_url, params=params)
data = response.json()

if response.status_code == 200:
# Parse the JSON data
city_name = data['name']
country = data['sys']['country']
temp = data['main']['temp']
humidity = data['main']['humidity']
wind_speed = data['wind']['speed']
description = data['weather'][0]['description']

# Update the UI labels
result_label.config(text=f"{city_name}, {country}")
temp_label.config(text=f"{temp}°C")
details_label.config(text=f"Condition: {description.title()}\n"
f"Humidity: {humidity}%\n"
f"Wind: {wind_speed} m/s")
else:
messagebox.showerror("Error", f"City not found.\n({data.get('message', '')})")

except requests.exceptions.RequestException as e:
messagebox.showerror("Connection Error", f"Could not connect to internet.\n{e}")

# --- GUI Setup ---
root = tk.Tk()
root.title("Weather Forecast App")
root.geometry("350x400")
root.configure(bg="#f0f0f0")

# Header
header_label = tk.Label(root, text="Weather App", font=("Helvetica", 20, "bold"), bg="#f0f0f0")
header_label.pack(pady=20)

# Input Field
city_entry = tk.Entry(root, font=("Helvetica", 14), width=20, justify='center')
city_entry.pack(pady=10)

# Search Button
search_button = tk.Button(root, text="Check Weather", font=("Helvetica", 12),
bg="#007bff", fg="white", command=get_weather)
search_button.pack(pady=10)

# --- Results Area ---
result_label = tk.Label(root, text="", font=("Helvetica", 18, "bold"), bg="#f0f0f0")
result_label.pack(pady=10)

temp_label = tk.Label(root, text="", font=("Helvetica", 30, "bold"), fg="#ff5722", bg="#f0f0f0")
temp_label.pack()

details_label = tk.Label(root, text="", font=("Helvetica", 12), bg="#f0f0f0")
details_label.pack(pady=20)

# Run the app
root.mainloop()

Conclusion

Building a Weather Forecast App using Python is a great way to learn API integration, live data handling, and application development. With features like city-wise search, temperature, wind, and humidity display, and OpenWeatherMap API usage, this project covers many important Python concepts.

Whether you are a beginner or an intermediate Python developer, this project adds real value to your learning and career. It is also an excellent topic for technical blogs and Medium backlinks because it is SEO-friendly, useful, and always relevant.

If you want more top Python Projects like that so now
click here

--

--

inprogrammer
inprogrammer

AI Engineer & storyteller. Translating machine learning, modern tech, and productivity into narratives worth your screen time.