0% found this document useful (0 votes)
3 views2 pages

Weather App Console Python Project

The Weather App is a command-line application built in Python that retrieves real-time weather data from the OpenWeatherMap API. It allows users to input a city name and displays the current temperature, weather conditions, humidity, and wind speed. This project serves as a practical exercise for Diploma 3rd Semester CSE students to learn API handling and JSON parsing.

Uploaded by

omdas8954
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)
3 views2 pages

Weather App Console Python Project

The Weather App is a command-line application built in Python that retrieves real-time weather data from the OpenWeatherMap API. It allows users to input a city name and displays the current temperature, weather conditions, humidity, and wind speed. This project serves as a practical exercise for Diploma 3rd Semester CSE students to learn API handling and JSON parsing.

Uploaded by

omdas8954
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/ 2

Weather App using Python (Console Based)

Introduction:

This Weather App is a simple command-line application built with Python. It uses real-time data from

the OpenWeatherMap API to provide weather updates like temperature, humidity, and conditions for

any city. This project is designed for Diploma 3rd Semester CSE students to demonstrate API

handling and JSON parsing using Python.

Requirements:

- Python 3.x

- requests module (install using: pip install requests)

- OpenWeatherMap API key (Free registration at https://openweathermap.org)

- Internet connection

Features:

- Input city name and get current weather

- Displays temperature in Celsius

- Shows weather condition, humidity, and wind speed

Python Code:

import requests

def get_weather(city_name, api_key):


url =
f"http://api.openweathermap.org/data/2.5/weather?q={city_name}&appid={api_key}&units=met
ric"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
print(f"\nWeather Report for {city_name}:")
print(f"Temperature: {data['main']['temp']}°C")
print(f"Condition: {data['weather'][0]['description']}")
print(f"Humidity: {data['main']['humidity']}%")
print(f"Wind Speed: {data['wind']['speed']} m/s")
else:
print("City not found or invalid API key.")

if __name__ == "__main__":
api_key = "your_api_key_here" # Replace with your actual API key
city = input("Enter city name: ")
get_weather(city, api_key)

Conclusion:

This basic weather app showcases how to build a real-world application using Python and REST

APIs. With further improvements, students can create a GUI version using Tkinter or add 5-day

forecasts.

You might also like