generated from mwc/lab_weather
I worked on the friends functions and the weather.
Checkpoint 1: I kind of hated how the test_friend_functions worked. It was overstimulating and I had to move my friend_functions code into the people code to test them out. I did end up getting correct results for the functions that I created but I couldm't figure out what was happening to these results when I ran them with test_friend_functions instead. I took too much time getting frustrated on this part so I decided to move on after thinking that I got the general gist of it. I also talked to Molly and we both thought this part was frustrating and moved on after a while. Checkpoint 2: This part of the lab was less frustrating than the one before. I guess understanding what the weather API did helped a lot as well as the practice from frined functions to call things appropriately. My general understanding of what all these systems have in common is that they all rely on inputs one way or the other. For more complex systems such as the weather that draws from online data, we also have to be careful with how to integrate and recall outputs to continue and then categorize them as we need.
This commit is contained in:
@@ -10,64 +10,46 @@
|
||||
# each and instead write code which returns the expected values.
|
||||
|
||||
def count_people(people):
|
||||
"""Counts the number of people.
|
||||
|
||||
>>> count_people(family)
|
||||
5
|
||||
>>> count_people(friends)
|
||||
10
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
count=0
|
||||
for person in people:
|
||||
if "name" in person:
|
||||
count=count+1
|
||||
print(count)
|
||||
|
||||
def get_email(people, name):
|
||||
"""Returns the named person's email address. If there is no such person, returns None.
|
||||
|
||||
>>> get_email(family, "Tad Winters")
|
||||
"ligula.aenean@hotmail.edu"
|
||||
>>> get_email(friends, "Tad Winters")
|
||||
None
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
email=""
|
||||
for person in people:
|
||||
if person["name"] == name:
|
||||
email=person["email"]
|
||||
print(f'"{email}"')
|
||||
return
|
||||
else:
|
||||
print("None")
|
||||
|
||||
def count_favorite_colors(people, name):
|
||||
"""Returns the number of colors liked by the named person. If there is no such person, returns None.
|
||||
for person in people:
|
||||
if person["name"] == name:
|
||||
numcolor=len(person["favorite_colors"])
|
||||
print(numcolor)
|
||||
return
|
||||
else:
|
||||
print("None")
|
||||
|
||||
>>> count_favorite_colors(family, "Tad Winters")
|
||||
2
|
||||
>>> count_favorite_colors(family, "Raphael Chambers")
|
||||
1
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def people_who_like_color(people, color):
|
||||
"""Returns a list containing only those people who like the given color.
|
||||
>>> people_who_like_color(family, "yellow")
|
||||
[
|
||||
{
|
||||
"name": "Walker Hurley",
|
||||
"email": "auctor.odio@icloud.ca",
|
||||
"favorite_colors": ["red", "yellow", "blue", "orange"],
|
||||
},
|
||||
{
|
||||
"name": "Clementine Joseph",
|
||||
"email": "hendrerit@aol.co.uk",
|
||||
"favorite_colors": ["yellow", "aqua", "black"],
|
||||
}
|
||||
]
|
||||
>>> people_who_like_color(family, "indigo")
|
||||
[]
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
for person in people:
|
||||
if color in person["favorite_colors"]:
|
||||
print(person)
|
||||
else:
|
||||
print([])
|
||||
|
||||
def count_people_who_like_color(people, color):
|
||||
"""Returns the number of people who like a given color.
|
||||
|
||||
>>> count_people_who_like_color(family, "red")
|
||||
2
|
||||
>>> count_people_who_like_color(family, "orange")
|
||||
1
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
colorcount=0
|
||||
for person in people:
|
||||
if color in person["favorite_colors"]:
|
||||
colorcount=colorcount+1
|
||||
print(colorcount)
|
||||
|
||||
|
||||
def get_color_dict(people):
|
||||
"""Returns a dict showing how many people like each color.
|
||||
|
||||
@@ -86,3 +86,12 @@ friends = [
|
||||
"favorite_colors": ["yellow"],
|
||||
}
|
||||
]
|
||||
|
||||
def count_people_who_like_color(people, color):
|
||||
colorcount=0
|
||||
for person in people:
|
||||
if color in person["favorite_colors"]:
|
||||
colorcount=colorcount+1
|
||||
print(colorcount)
|
||||
|
||||
count_people_who_like_color(friends, "grey")
|
||||
24
weather/.history/weather_20250912140933.py
Normal file
24
weather/.history/weather_20250912140933.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
print("Not finished...") # YOUR CODE HERE!
|
||||
40
weather/.history/weather_20251025165649.py
Normal file
40
weather/.history/weather_20251025165649.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
latlong=lct['lat', 'lng']
|
||||
weatheroffice=get_weather_office(latlong)
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], ['x'], ['y'])
|
||||
if not forecast:
|
||||
print('None')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
print("Not finished...") # YOUR CODE HERE!
|
||||
40
weather/.history/weather_20251025165650.py
Normal file
40
weather/.history/weather_20251025165650.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
latlong=lct['lat', 'lng']
|
||||
weatheroffice=get_weather_office(latlong)
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], ['x'], ['y'])
|
||||
if not forecast:
|
||||
print('None')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
print("Not finished...") # YOUR CODE HERE!
|
||||
40
weather/.history/weather_20251025165943.py
Normal file
40
weather/.history/weather_20251025165943.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
latlong=lct['lat'],lct ['lng']
|
||||
weatheroffice=get_weather_office(latlong)
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], ['x'], ['y'])
|
||||
if not forecast:
|
||||
print('None')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
print("Not finished...") # YOUR CODE HERE!
|
||||
40
weather/.history/weather_20251025165946.py
Normal file
40
weather/.history/weather_20251025165946.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
latlong=lct['lat'],lct ['lng']
|
||||
weatheroffice=get_weather_office(latlong)
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], ['x'], ['y'])
|
||||
if not forecast:
|
||||
print('None')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
print("Not finished...") # YOUR CODE HERE!
|
||||
39
weather/.history/weather_20251025170028.py
Normal file
39
weather/.history/weather_20251025170028.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], ['x'], ['y'])
|
||||
if not forecast:
|
||||
print('None')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
print("Not finished...") # YOUR CODE HERE!
|
||||
39
weather/.history/weather_20251025170031.py
Normal file
39
weather/.history/weather_20251025170031.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], ['x'], ['y'])
|
||||
if not forecast:
|
||||
print('None')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
print("Not finished...") # YOUR CODE HERE!
|
||||
43
weather/.history/weather_20251025171452.py
Normal file
43
weather/.history/weather_20251025171452.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
print(f"Temperature: {}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
print("Not finished...") # YOUR CODE HERE!
|
||||
43
weather/.history/weather_20251025171456.py
Normal file
43
weather/.history/weather_20251025171456.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
print(f"Temperature: {}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
print("Not finished...") # YOUR CODE HERE!
|
||||
43
weather/.history/weather_20251025171700.py
Normal file
43
weather/.history/weather_20251025171700.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"Temperature: {period['temperature'], 'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
43
weather/.history/weather_20251025171702.py
Normal file
43
weather/.history/weather_20251025171702.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"Temperature: {period['temperature'], 'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
43
weather/.history/weather_20251025171703.py
Normal file
43
weather/.history/weather_20251025171703.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"Temperature: {period['temperature'], 'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
43
weather/.history/weather_20251025171732.py
Normal file
43
weather/.history/weather_20251025171732.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"Temperature: {period['temperature'], 'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
43
weather/.history/weather_20251025171734.py
Normal file
43
weather/.history/weather_20251025171734.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"Temperature: {period['temperature'], 'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
43
weather/.history/weather_20251025172020.py
Normal file
43
weather/.history/weather_20251025172020.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"Temperature: {period['temperature']}, {'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
43
weather/.history/weather_20251025172023.py
Normal file
43
weather/.history/weather_20251025172023.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"Temperature: {period['temperature']}, {'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
43
weather/.history/weather_20251025172024.py
Normal file
43
weather/.history/weather_20251025172024.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"Temperature: {period['temperature']}, {'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
43
weather/.history/weather_20251025172102.py
Normal file
43
weather/.history/weather_20251025172102.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
43
weather/.history/weather_20251025172104.py
Normal file
43
weather/.history/weather_20251025172104.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
46
weather/.history/weather_20251025172255.py
Normal file
46
weather/.history/weather_20251025172255.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
46
weather/.history/weather_20251025172257.py
Normal file
46
weather/.history/weather_20251025172257.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
else:
|
||||
lct=estimate_location()
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {lct if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172510.py
Normal file
48
weather/.history/weather_20251025172510.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172511.py
Normal file
48
weather/.history/weather_20251025172511.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172636.py
Normal file
48
weather/.history/weather_20251025172636.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}\n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172637.py
Normal file
48
weather/.history/weather_20251025172637.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}\n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172647.py
Normal file
48
weather/.history/weather_20251025172647.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}\n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172648.py
Normal file
48
weather/.history/weather_20251025172648.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}\n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172650.py
Normal file
48
weather/.history/weather_20251025172650.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}\n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172712.py
Normal file
48
weather/.history/weather_20251025172712.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}\n ______________")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172713.py
Normal file
48
weather/.history/weather_20251025172713.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}\n ______________")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172728.py
Normal file
48
weather/.history/weather_20251025172728.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172729.py
Normal file
48
weather/.history/weather_20251025172729.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
48
weather/.history/weather_20251025172730.py
Normal file
48
weather/.history/weather_20251025172730.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('None')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('None')
|
||||
print(f"Location: {location if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
|
||||
40
weather/.history/weather_20251025173403.py
Normal file
40
weather/.history/weather_20251025173403.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {location if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['windDirection']}")
|
||||
print(f"Wind Speed: {period['windSpeed']}")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173404.py
Normal file
40
weather/.history/weather_20251025173404.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {location if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['windDirection']}")
|
||||
print(f"Wind Speed: {period['windSpeed']}")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173531.py
Normal file
40
weather/.history/weather_20251025173531.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {location if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173532.py
Normal file
40
weather/.history/weather_20251025173532.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {location if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173846.py
Normal file
40
weather/.history/weather_20251025173846.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {show_lct if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173847.py
Normal file
40
weather/.history/weather_20251025173847.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {show_lct if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173848.py
Normal file
40
weather/.history/weather_20251025173848.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {show_lct if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}\n")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173907.py
Normal file
40
weather/.history/weather_20251025173907.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {show_lct if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}\n")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173908.py
Normal file
40
weather/.history/weather_20251025173908.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {show_lct if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}\n")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173910.py
Normal file
40
weather/.history/weather_20251025173910.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {show_lct if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}\n")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173927.py
Normal file
40
weather/.history/weather_20251025173927.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {show_lct if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}\n")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173930.py
Normal file
40
weather/.history/weather_20251025173930.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {show_lct if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}\n")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173938.py
Normal file
40
weather/.history/weather_20251025173938.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {show_lct if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}\n")
|
||||
|
||||
|
||||
40
weather/.history/weather_20251025173940.py
Normal file
40
weather/.history/weather_20251025173940.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# weather.py
|
||||
# ------------
|
||||
# By MWC Contributors
|
||||
#
|
||||
# Defines `print_weather`, which does all the work of fetching
|
||||
# the requested weather data and printing it out to the screen
|
||||
# in a sensible way.
|
||||
#
|
||||
# It's your job to implement this function.
|
||||
|
||||
from weather.weather_apis import (
|
||||
geocode_location,
|
||||
estimate_location,
|
||||
get_weather_office,
|
||||
get_forecast
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {show_lct if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}\n")
|
||||
|
||||
|
||||
@@ -16,9 +16,25 @@ from weather.weather_apis import (
|
||||
)
|
||||
|
||||
def print_weather(location=None, metric=False, verbose=False):
|
||||
"""Prints out a weather report using the provided location, or using
|
||||
the user's current location if no location was provided.
|
||||
When metric is True, prints out the weather in metric units.
|
||||
When verbose is True, prints out a more detailed report.
|
||||
"""
|
||||
print("Not finished...") # YOUR CODE HERE!
|
||||
if location:
|
||||
lct=geocode_location(location)
|
||||
show_lct=location
|
||||
else:
|
||||
lct=estimate_location()
|
||||
show_lct="Estimate location"
|
||||
weatheroffice=get_weather_office(lct['lat'],lct ['lng'])
|
||||
if not weatheroffice:
|
||||
print('Unable to find weather office data')
|
||||
forecast=get_forecast(weatheroffice['office'], weatheroffice['x'], weatheroffice['y'], metric=metric)
|
||||
if not forecast:
|
||||
print('Unable to retrieve forecast data')
|
||||
print(f"Location: {show_lct if location else estimate_location()}\n ______________ \n")
|
||||
for period in forecast:
|
||||
print(f"{period['name']}")
|
||||
print(f"Description: {period['description']}")
|
||||
print(f"Temperature: {period['temperature']}{'C' if metric else 'F'}")
|
||||
if verbose:
|
||||
print(f"Wind Direction: {period['wind_direction']}")
|
||||
print(f"Wind Speed: {period['wind_speed']}\n")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user