Cobra_Pro

🌦️ Introduction

The current image has no alternative text. The file name is: KIN.jpg

In this project, you’ll build a Weather App in Python that retrieves live weather information from an online API.
You’ll learn how to work with HTTP requests, JSON data, and API keys — essential skills for modern developers.


🧠 Key Concepts Covered

ConceptDescription
APIsApplication Programming Interfaces — services that let your code talk to other systems.
Requests ModuleA Python library used to send HTTP requests and receive data.
JSON ParsingConverting JSON data into Python dictionaries for easy handling.

🧰 What You’ll Need

  • Python 3 installed
  • requests library (install with pip install requests)
  • Free API key from OpenWeatherMap

💻 Step-by-Step Code

File Name: weather_app.py

import requests

# 🔑 Replace with your own API key
API_KEY = "your_api_key_here"
BASE_URL = "https://api.openweathermap.org/data/2.5/weather"

print("🌤️ Welcome to the Python Weather App!")

city = input("🏙️ Enter city name: ")

# Build full URL with parameters
params = {
    "q": city,
    "appid": API_KEY,
    "units": "metric"
}

response = requests.get(BASE_URL, params=params)

if response.status_code == 200:
    data = response.json()
    main = data["main"]
    weather = data["weather"][0]
    
    print(f"\n📍 City: {data['name']}")
    print(f"🌡️ Temperature: {main['temp']}°C")
    print(f"💧 Humidity: {main['humidity']}%")
    print(f"☁️ Condition: {weather['description'].title()}")
else:
    print("⚠️ City not found or API error.")

🧩 Example Output

🌤️ Welcome to the Python Weather App!
🏙️ Enter city name: London

📍 City: London
🌡️ Temperature: 17.5°C
💧 Humidity: 62%
☁️ Condition: Light Rain

🧠 How It Works
  1. The user inputs a city name.
  2. Python sends a GET request to the OpenWeatherMap API.
  3. The app retrieves the JSON response, which includes temperature, humidity, and condition.
  4. It then displays the data neatly in the console.

⚙️ Improvements You Can Add
  • Convert temperature between Celsius and Fahrenheit.
  • Display wind speed and pressure.
  • Build a GUI version using tkinter.
  • Create a daily forecast version with extended API endpoints.

📝 Summary
  • You learned how to interact with an external API using Python.
  • You practiced JSON parsing and error handling.
  • You built a real-time Weather App ready for future improvements.
⬇️ Download cobra_king تحميل Server 1

Related Posts

Fiveg_Tv

🔐 Project Overview In this project, you will create a secure Password Manager that : ✔ Saves usernames & passwords✔ Encrypts all data✔ Stores everything in a JSON file✔ Allows…

Read more

Djoker_tv

🧾 Project Overview In this project, you will build a Python Expense Tracker App that allows users to: ✔ Add new expenses✔ View all expenses✔ Search by category✔ Calculate total…

Read more

FlyFeditv

📘 Introduction In this project, you’ll create a command-line Expense Tracker that allows users to: ✅ Add expenses with category, amount, and description✅ View total spending and category breakdown✅ Automatically…

Read more

NetCinFly

📘 Introduction In this project, you’ll develop a Student Grades Analyzer in Python that can: This project helps you strengthen your skills with lists, dictionaries, loops, and data analysis logic….

Read more

Eagle_Pro

🌐 Introduction In this project, you’ll create a Web Scraper App in Python that extracts quotes, authors, and tags from a live website.You’ll use the BeautifulSoup and Requests libraries to…

Read more

Show7-Pro

Concepts Covered: 🎯 Objective: Create a simple, text-based contact book application that allows users to: 💡 Code (contact_book.py): 🧠 Example Usage Console Output Example: 💾 Notes ⬇️ Download Show7-Pro تحميل…

Read more