-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurrent_Weather.py
More file actions
29 lines (23 loc) · 1.17 KB
/
Current_Weather.py
File metadata and controls
29 lines (23 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import requests
API_ENDPOINT = "http://api.weatherapi.com/v1/current.json" #Current Weather
KEY = "fed9cc83b6b241a380c185639250502"
LOCATION = "Bhubaneswar"
PARAMETER = {
"key" : KEY,
"q" : LOCATION,
"aqi" : "no"
}
weather_details = requests.get(url = API_ENDPOINT, params = PARAMETER)
weather_details.raise_for_status()
currentWeather = weather_details.json()
# print(currentWeather)
printDetails = f"""Location: {currentWeather["location"]["name"]}, {currentWeather["location"]["region"]}, {currentWeather["location"]["country"]}
Latitude: {currentWeather["location"]["lat"]} Longitude: {currentWeather["location"]["lon"]}
Timezone: {currentWeather["location"]["tz_id"]}
Temperature: {currentWeather["current"]["temp_c"]}°C or {currentWeather["current"]["temp_f"]}°F
Feels like: {currentWeather["current"]["feelslike_c"]}°C or {currentWeather["current"]["feelslike_f"]}°F
Current Condition: {currentWeather["current"]["condition"]["text"]}
Wind Intensity: {currentWeather["current"]["wind_mph"]}mph or {currentWeather["current"]["wind_kph"]}kph, Direction: {currentWeather["current"]["wind_dir"]}
Humidity: {currentWeather["current"]["humidity"]}%
"""
print(printDetails)