-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeather app.py
52 lines (36 loc) · 1.88 KB
/
Weather app.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Weather App by Akash Halder
import requests
import json
import win32com.client as wincom
speak = wincom.Dispatch( "SAPI.SpVoice" )
print("Hello there! Welcome to Akash's Weather App")
# print( "============ Welcome to Akash's Weather App (version=1.1.1) ===========" )
speak.Speak("Hello there!Welcome to Akash's Weather App")
# speak.Speak( "Enter the name of your city:" )
while True:
try:
print("=================== Akash's Weather App (version=1.1.1) ==================")
print("To know the temperature of your city please enter the name of your city: \n")
print( "To Exit the weather app type 'exit' in input:" )
speak.Speak("To know the temperature of your city please enter the name of your city:")
city = str(input("Enter the name of your country / city: \n"))
url = f"https://api.weatherapi.com/v1/current.json?key=dc5799ac63574ee9a66182700230807&q={city}"
if (city == "exit"):
print("Bye Bye my friend 👋🏼. \nThanks for using Akash's Weather App.")
speak.Speak("Bye Bye my friend. \nThanks for using Akash's Weather App.")
break
r = requests.get(url)
# print(r.text)
# print(type(r.text))
wdic = json.loads(r.text)
w = (wdic["current"]["temp_c"])
# if city == str:
# speak.Speak("Alright! Let me Check")
# elif city == int:
# speak.Speak("Please Enter your City name correctly")
print(f"The current temperature in {city} is {w} degrees Celsius")
speak.Speak(f"The current temperature in{city} is {w} degrees Celsius")
except:
print("Sorry!Something went wrong... try again 🔃",)
speak.Speak("Sorry!Something went wrong... try again")
# This app is built by Akash using Pure Python Only...Not any other extensions excluding modules