Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import datetime
- import random
- city = input("Choose city: ")
- def calendar_day():
- today = datetime.datetime.today()
- print(f"""
- Today we have {today.day} day of the {today.month} month {today.year} year
- The day of the week is: {today.strftime('%A')}
- Time now is {today.hour}:{today.strftime('%M')}""")
- def weather_api():
- querystring = {"q":"","lat":"0","lon":"0","id":"2172797","lang":"null","units":"metric" ,"mode":"xml, html"}
- querystring["q"] = city
- url = "https://community-open-weather-map.p.rapidapi.com/weather"
- headers = {
- 'x-rapidapi-key': "83f6c748c0msh05c1107692f8917p14e71ajsnf6435b6b138a",
- 'x-rapidapi-host': "community-open-weather-map.p.rapidapi.com"
- }
- response = requests.request("GET", url, headers=headers, params=querystring).json()
- weather_info(response)
- def weather_info(response):
- if response:
- print(f"""
- Weather: {response['weather'][0]['main']}
- Detailed weather: {response['weather'][0]['description']}
- Temperature: {response['main']['temp']} C
- Pressure: {response['main']['pressure']}""")
- else:
- print("Something goes wrong!")
- def quote_of_the_day():
- url_quote = "https://type.fit/api/quotes"
- quote_response = random.choice(requests.request("GET", url_quote).json())
- print(f"""
- Quote for you today: {quote_response['text']}
- Quote author: {quote_response['author']}""")
- quote_of_the_day()
- calendar_day()
- weather_api()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement