Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dfe0df2

Browse files
Merge pull request avinashkranjan#2039 from Kalivarapubindusree/weather
Current_City_Weather Added
2 parents 329e76a + 4ee706a commit dfe0df2

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import requests
2+
3+
4+
def get_temperature(json_data):
5+
temp_in_celcius = json_data['main']['temp']
6+
return temp_in_celcius
7+
8+
def get_weather_type(json_data):
9+
weather_type = json_data['weather'][0]['description']
10+
return weather_type
11+
12+
def get_wind_speed(json_data):
13+
wind_speed = json_data['wind']['speed']
14+
return wind_speed
15+
16+
17+
18+
def get_weather_data(json_data, city):
19+
description_of_weather = json_data['weather'][0]['description']
20+
weather_type = get_weather_type(json_data)
21+
temperature = get_temperature(json_data)
22+
wind_speed = get_wind_speed(json_data)
23+
weather_details = ''
24+
return weather_details + ("The weather in {} is currently {} with a temperature of {} degrees and wind speeds reaching {} km/ph".format(city, weather_type, temperature, wind_speed))
25+
26+
27+
def main():
28+
api_address = 'https://api.openweathermap.org/data/2.5/weather?q=Sydney,au&appid=a10fd8a212e47edf8d946f26fb4cdef8&q='
29+
city = input("City Name : ")
30+
units_format = "&units=metric"
31+
final_url = api_address + city + units_format
32+
json_data = requests.get(final_url).json()
33+
weather_details = get_weather_data(json_data, city)
34+
# print formatted data
35+
print(weather_details)
36+
37+
38+
39+
main()

‎Current_City_Weather/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
**Current_City_Weather**
2+
3+
4+
5+
**How to Use:**
6+
This Script is an Current_City_Weather before that we need to import requestsThen just we need to run Current_City_Weather.py simple and easy to use.
7+
8+
9+
**conclusion:**
10+
11+
This Just a Script That we can allow to check Current_City_Weather from the terminal itself!
12+
13+
#### By [Kalivarapubindusree]()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /