From 18b79d43444be21536a231cffe0bcdf6adf03f6d Mon Sep 17 00:00:00 2001 From: Srinjoy Pati Date: Fri, 30 Sep 2022 23:58:50 +0530 Subject: [PATCH 1/2] added weather detector --- scripts/Weather-teller/README.md | 35 +++++++++++++++++++++++++++ scripts/Weather-teller/weather-det.py | 21 ++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 scripts/Weather-teller/README.md create mode 100644 scripts/Weather-teller/weather-det.py diff --git a/scripts/Weather-teller/README.md b/scripts/Weather-teller/README.md new file mode 100644 index 0000000..64a70aa --- /dev/null +++ b/scripts/Weather-teller/README.md @@ -0,0 +1,35 @@ +# Weather-teller + +## Introduction +This project , Asks the user the name of a city as input and provides the weather and temperature(in celsius) as output. + +## Tech stack + +The project is made using python and weather API. +The weather API , I hv used in this project is from - https://openweathermap.org/api + +## Demonstration video - here is a view of the project : + +https://user-images.githubusercontent.com/91176055/159108679-8124cd46-7467-465a-9674-c32e42361ed7.mp4 + + +## Install dependencies +- install Python 3.8.3 or above +- Sign up on https://openweathermap.org/api and you would get your API key. +- Further install this package using terminal: + +```bash + pip install requests +``` +## Quick start (how to run locally) + +- Clone this repository: +```bash +git clone https://github.com/pranjay-poddar/Dev-Geeks.git +``` +- Change directory: +```bash +cd ML Projects +cd Weather-teller +``` +- Find main.py and run it. diff --git a/scripts/Weather-teller/weather-det.py b/scripts/Weather-teller/weather-det.py new file mode 100644 index 0000000..82bdf47 --- /dev/null +++ b/scripts/Weather-teller/weather-det.py @@ -0,0 +1,21 @@ +import requests + + +API_KEY = "b09dc0e32c95634996021e1c49d7a751" +BASE_URL = "http://api.openweathermap.org/data/2.5/weather" + +city = input("enter a city name: ") +request_url = f"{BASE_URL}?appid={API_KEY}&q={city}" +response = requests.get(request_url) + + +if response.status_code == 200: + data = response.json() + weather = data['weather'][0]['description'] + temperature = round(data["main"]["temp"] - 273.15, 2) + + + print("Weather:", weather) + print("Temperature:", temperature, "celsius") +else: + print("an error occurred.") From eeb6a5880ba35378aca8a4c474dce5ed9a480a25 Mon Sep 17 00:00:00 2001 From: srinjoy pati <91176055+srinjoy-26@users.noreply.github.com> Date: Sat, 1 Oct 2022 00:07:28 +0530 Subject: [PATCH 2/2] Update README.md --- scripts/Weather-teller/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/Weather-teller/README.md b/scripts/Weather-teller/README.md index 64a70aa..fa96371 100644 --- a/scripts/Weather-teller/README.md +++ b/scripts/Weather-teller/README.md @@ -25,11 +25,11 @@ https://user-images.githubusercontent.com/91176055/159108679-8124cd46-7467-465a- - Clone this repository: ```bash -git clone https://github.com/pranjay-poddar/Dev-Geeks.git +git clone https://github.com/metafy-social/daily-python-scripts ``` - Change directory: ```bash -cd ML Projects +cd scripts cd Weather-teller ``` -- Find main.py and run it. +- Find weather-det.py and run it.