forked from Rainiefeng/final-report
-
Notifications
You must be signed in to change notification settings - Fork 0
/
final project.py
28 lines (23 loc) · 904 Bytes
/
final project.py
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
key = "219b74026949c164fc504f625a7b805c"
url = "http://api.openweathermap.org/data/2.5/weather?"
city_name = input("Enter city name : ")
complete_url = url + "appid=" + key + "&q=" + city_name
response = requests.get(complete_url)
data = response.json()
if data["cod"] != "404":
base = data["main"]
current_temperature = base["temp"]
current_pressure = base["pressure"]
current_humidiy = base["humidity"]
weather = data["weather"]
weather_description = weather[0]["description"]
print(" Temperature (in kelvin unit) = " +
str(current_temperature) +
"\n atmospheric pressure (in hPa unit) = " +
str(current_pressure) +
"\n humidity (in percentage) = " +
str(current_humidiy) +
"\n description = " +
str(weather_description))
else:
print(" City Not Found ")