Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from srinjoy-26/scri
added weather teller
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/metafy-social/daily-python-scripts | ||
``` | ||
- Change directory: | ||
```bash | ||
cd scripts | ||
cd Weather-teller | ||
``` | ||
- Find weather-det.py and run it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.") |