python
python
MICRO-PROJECT REPORT
We wish to express our professor gratitude to our guide Prof.P.P ANGADI who guided us
endlessly in framing and completion of Micro-Project. He guided us on all the main points in
that Micro-Project. We are indebted to his constant encouragement, cooperation and help. It
was his enthusiastic support that helped us in overcoming of various obstacles in the Micro-
Project.
We are also thankful to our Principal, HOD, Faculty Members and classmates for extending
their support and motivation in the completion of this Micro-Project.
❖INTRODUCTION
In this Weather Forecasting in Python project, the goal is to utilize Python’s robust
libraries and machine learning techniques to predict weather conditions such as
temperature, humidity, precipitation, and wind speed. By integrating real-time weather
data from APIs (such as OpenWeatherMap or WeatherStack) and utilizing statistical
and machine learning models, this project will demonstrate how Python can be used
for building reliable weather forecasting applications.
❖ TECHNOLOGY STACK
1. Programming Language:
2. Libraries/Modules:
• requests:
o Used for sending HTTP requests to the weather API to fetch data (e.g.,
current weather, temperature, humidity, etc.).
o Makes it easy to interact with APIs and retrieve information in JSON
format.
o Example usage:
import requests
response = requests.get('API_URL')
data = response.json()
json:
• Python's built-in library to parse and manipulate JSON data returned from the
API.
• JSON is a common data format used by most weather APIs to send the data.
import tkinter as tk
root = tk.Tk()
label = tk.Label(root, text="Enter city:")
label.pack()
root.mainloop()
3. Weather API:
http://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_KEY}&unit
s=metric
• JSON:
o Weather data is returned as a JSON object. Using Python's built-in json
library, you can parse this data and extract specific fields such as
temperature, weather condition, humidity, etc.
o Example:
weather = data['weather'][0]['description']
temperature = data['main']['temp']
❖ FUNCTIONAL REQUREMENT
1. User Input:
o The application should allow the user to input the name of the city for
which they want to fetch the weather forecast.
o Input should be case-insensitive (e.g., "London" or "london" should both
work).
2. Weather Data Fetching:
o The program should fetch real-time weather data from a public weather
API (e.g., OpenWeatherMap).
o The data should include details like:
▪ Current temperature (in Celsius or Fahrenheit).
▪ Weather condition (e.g., clear, cloudy, rainy).
▪ Humidity (percentage).
▪ Wind speed (m/s).
▪ Pressure (optional).
3. Display Weather Information:
o The application should display the fetched weather details clearly to the
user.
o This can be done via the console or a graphical interface (GUI) using
tkinter.
4. Error Handling:
o The application should handle errors gracefully:
▪ City not found: If the user inputs an invalid or non-existent city,
display an error message.
▪ API failure: If the API fails or there is no internet connection,
inform the user.
▪ Invalid Input: Handle invalid input (e.g., empty or incorrect city
name).
5. Output Formatting:
o The output should be formatted for readability (e.g., "Temperature:
25°C", "Weather: Clear").
o Display relevant information based on what the API returns.
6. Multi-day Forecast:
o You can add functionality to show the weather forecast for the next few
days (e.g., a 5-day forecast).
o This would involve parsing the forecast data from the API and displaying
it in a structured way.
❖ NON FUNCTIONAL REQUIREMENT
1. Performance:
o The application should fetch and display the weather data quickly
(typically within a few seconds).
o Efficient use of the API to minimize delays when making requests and
processing responses.
2. Usability:
o The tool should be easy to use, with a simple input prompt (for console
version) or a user-friendly GUI (for GUI version).
o The output should be clear, well-organized, and easily understandable by
non-technical users.
3. Reliability:
o The application should handle potential failures (e.g., API downtime, no
internet connection) gracefully, without crashing.
o It should provide clear error messages and instructions to the user if
something goes wrong.
4. Scalability:
o While this is a small project, it should be designed in a way that allows
for easy updates (e.g., adding multi-day forecasts or more detailed
weather data) in the future.
5. Maintainability:
o The code should be well-structured and modular, with clear comments
and documentation, making it easy to maintain and extend.
o Use of functions to separate different tasks (e.g., fetching data, processing
data, displaying results) will make it easier to modify or expand.
6. Compatibility:
o The application should be compatible with different operating systems
(e.g., Windows, macOS, Linux) for the console version.
o If a GUI is implemented using tkinter, it should work across common
platforms without issues.
7. Security:
o The application should securely handle API keys (if used), either by
storing them in a configuration file or environment variables, and avoid
hardcoding sensitive information in the code.
8. Availability:
o The application should be available for use at any time, as long as the
API service is functioning and the user has an internet connection.
❖CODING
Steps to Follow:
import requests
# Main function to take user input and call the weather function
def main():
# Get the API key (you need to sign up and get a free API key from OpenWeatherMap)
api_key = "YOUR_API_KEY" # Replace with your actual API key from OpenWeatherMap
python weather_forecast.py
Enter the name of the city when prompted, and it will show the weather information.
❖OUTPUT
(A) (B)
Process and Product Individual Presentation/ Total Marks
Assessment (6 marks) Viva (4 marks) 10
Signature:-