diff --git a/friend_functions.py b/friend_functions.py index 6f5ecf7..83a460f 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -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. diff --git a/people.py b/people.py index 68ea27e..dae82e7 100644 --- a/people.py +++ b/people.py @@ -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") \ No newline at end of file diff --git a/weather/.history/weather_20250912140933.py b/weather/.history/weather_20250912140933.py new file mode 100644 index 0000000..75fd2f6 --- /dev/null +++ b/weather/.history/weather_20250912140933.py @@ -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! diff --git a/weather/.history/weather_20251025165649.py b/weather/.history/weather_20251025165649.py new file mode 100644 index 0000000..6ea3f92 --- /dev/null +++ b/weather/.history/weather_20251025165649.py @@ -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! diff --git a/weather/.history/weather_20251025165650.py b/weather/.history/weather_20251025165650.py new file mode 100644 index 0000000..6ea3f92 --- /dev/null +++ b/weather/.history/weather_20251025165650.py @@ -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! diff --git a/weather/.history/weather_20251025165943.py b/weather/.history/weather_20251025165943.py new file mode 100644 index 0000000..5c0ecb8 --- /dev/null +++ b/weather/.history/weather_20251025165943.py @@ -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! diff --git a/weather/.history/weather_20251025165946.py b/weather/.history/weather_20251025165946.py new file mode 100644 index 0000000..5c0ecb8 --- /dev/null +++ b/weather/.history/weather_20251025165946.py @@ -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! diff --git a/weather/.history/weather_20251025170028.py b/weather/.history/weather_20251025170028.py new file mode 100644 index 0000000..e73c0be --- /dev/null +++ b/weather/.history/weather_20251025170028.py @@ -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! diff --git a/weather/.history/weather_20251025170031.py b/weather/.history/weather_20251025170031.py new file mode 100644 index 0000000..e73c0be --- /dev/null +++ b/weather/.history/weather_20251025170031.py @@ -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! diff --git a/weather/.history/weather_20251025171452.py b/weather/.history/weather_20251025171452.py new file mode 100644 index 0000000..1eabd13 --- /dev/null +++ b/weather/.history/weather_20251025171452.py @@ -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! diff --git a/weather/.history/weather_20251025171456.py b/weather/.history/weather_20251025171456.py new file mode 100644 index 0000000..1eabd13 --- /dev/null +++ b/weather/.history/weather_20251025171456.py @@ -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! diff --git a/weather/.history/weather_20251025171700.py b/weather/.history/weather_20251025171700.py new file mode 100644 index 0000000..3cf79cf --- /dev/null +++ b/weather/.history/weather_20251025171700.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025171702.py b/weather/.history/weather_20251025171702.py new file mode 100644 index 0000000..3cf79cf --- /dev/null +++ b/weather/.history/weather_20251025171702.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025171703.py b/weather/.history/weather_20251025171703.py new file mode 100644 index 0000000..3cf79cf --- /dev/null +++ b/weather/.history/weather_20251025171703.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025171732.py b/weather/.history/weather_20251025171732.py new file mode 100644 index 0000000..3cf79cf --- /dev/null +++ b/weather/.history/weather_20251025171732.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025171734.py b/weather/.history/weather_20251025171734.py new file mode 100644 index 0000000..3cf79cf --- /dev/null +++ b/weather/.history/weather_20251025171734.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172020.py b/weather/.history/weather_20251025172020.py new file mode 100644 index 0000000..ab4650e --- /dev/null +++ b/weather/.history/weather_20251025172020.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172023.py b/weather/.history/weather_20251025172023.py new file mode 100644 index 0000000..ab4650e --- /dev/null +++ b/weather/.history/weather_20251025172023.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172024.py b/weather/.history/weather_20251025172024.py new file mode 100644 index 0000000..ab4650e --- /dev/null +++ b/weather/.history/weather_20251025172024.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172102.py b/weather/.history/weather_20251025172102.py new file mode 100644 index 0000000..da34a52 --- /dev/null +++ b/weather/.history/weather_20251025172102.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172104.py b/weather/.history/weather_20251025172104.py new file mode 100644 index 0000000..da34a52 --- /dev/null +++ b/weather/.history/weather_20251025172104.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172255.py b/weather/.history/weather_20251025172255.py new file mode 100644 index 0000000..978ae38 --- /dev/null +++ b/weather/.history/weather_20251025172255.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172257.py b/weather/.history/weather_20251025172257.py new file mode 100644 index 0000000..978ae38 --- /dev/null +++ b/weather/.history/weather_20251025172257.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172510.py b/weather/.history/weather_20251025172510.py new file mode 100644 index 0000000..18658de --- /dev/null +++ b/weather/.history/weather_20251025172510.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172511.py b/weather/.history/weather_20251025172511.py new file mode 100644 index 0000000..18658de --- /dev/null +++ b/weather/.history/weather_20251025172511.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172636.py b/weather/.history/weather_20251025172636.py new file mode 100644 index 0000000..2b090a3 --- /dev/null +++ b/weather/.history/weather_20251025172636.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172637.py b/weather/.history/weather_20251025172637.py new file mode 100644 index 0000000..2b090a3 --- /dev/null +++ b/weather/.history/weather_20251025172637.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172647.py b/weather/.history/weather_20251025172647.py new file mode 100644 index 0000000..2b090a3 --- /dev/null +++ b/weather/.history/weather_20251025172647.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172648.py b/weather/.history/weather_20251025172648.py new file mode 100644 index 0000000..2b090a3 --- /dev/null +++ b/weather/.history/weather_20251025172648.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172650.py b/weather/.history/weather_20251025172650.py new file mode 100644 index 0000000..2b090a3 --- /dev/null +++ b/weather/.history/weather_20251025172650.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172712.py b/weather/.history/weather_20251025172712.py new file mode 100644 index 0000000..65fb90e --- /dev/null +++ b/weather/.history/weather_20251025172712.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172713.py b/weather/.history/weather_20251025172713.py new file mode 100644 index 0000000..65fb90e --- /dev/null +++ b/weather/.history/weather_20251025172713.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172728.py b/weather/.history/weather_20251025172728.py new file mode 100644 index 0000000..938010e --- /dev/null +++ b/weather/.history/weather_20251025172728.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172729.py b/weather/.history/weather_20251025172729.py new file mode 100644 index 0000000..938010e --- /dev/null +++ b/weather/.history/weather_20251025172729.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025172730.py b/weather/.history/weather_20251025172730.py new file mode 100644 index 0000000..938010e --- /dev/null +++ b/weather/.history/weather_20251025172730.py @@ -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. + """ + diff --git a/weather/.history/weather_20251025173403.py b/weather/.history/weather_20251025173403.py new file mode 100644 index 0000000..7a0a351 --- /dev/null +++ b/weather/.history/weather_20251025173403.py @@ -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']}") + + diff --git a/weather/.history/weather_20251025173404.py b/weather/.history/weather_20251025173404.py new file mode 100644 index 0000000..7a0a351 --- /dev/null +++ b/weather/.history/weather_20251025173404.py @@ -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']}") + + diff --git a/weather/.history/weather_20251025173531.py b/weather/.history/weather_20251025173531.py new file mode 100644 index 0000000..671105a --- /dev/null +++ b/weather/.history/weather_20251025173531.py @@ -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']}") + + diff --git a/weather/.history/weather_20251025173532.py b/weather/.history/weather_20251025173532.py new file mode 100644 index 0000000..671105a --- /dev/null +++ b/weather/.history/weather_20251025173532.py @@ -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']}") + + diff --git a/weather/.history/weather_20251025173846.py b/weather/.history/weather_20251025173846.py new file mode 100644 index 0000000..59445d9 --- /dev/null +++ b/weather/.history/weather_20251025173846.py @@ -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']}") + + diff --git a/weather/.history/weather_20251025173847.py b/weather/.history/weather_20251025173847.py new file mode 100644 index 0000000..59445d9 --- /dev/null +++ b/weather/.history/weather_20251025173847.py @@ -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']}") + + diff --git a/weather/.history/weather_20251025173848.py b/weather/.history/weather_20251025173848.py new file mode 100644 index 0000000..59445d9 --- /dev/null +++ b/weather/.history/weather_20251025173848.py @@ -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']}") + + diff --git a/weather/.history/weather_20251025173907.py b/weather/.history/weather_20251025173907.py new file mode 100644 index 0000000..1f532bf --- /dev/null +++ b/weather/.history/weather_20251025173907.py @@ -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") + + diff --git a/weather/.history/weather_20251025173908.py b/weather/.history/weather_20251025173908.py new file mode 100644 index 0000000..1f532bf --- /dev/null +++ b/weather/.history/weather_20251025173908.py @@ -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") + + diff --git a/weather/.history/weather_20251025173910.py b/weather/.history/weather_20251025173910.py new file mode 100644 index 0000000..1f532bf --- /dev/null +++ b/weather/.history/weather_20251025173910.py @@ -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") + + diff --git a/weather/.history/weather_20251025173927.py b/weather/.history/weather_20251025173927.py new file mode 100644 index 0000000..1f532bf --- /dev/null +++ b/weather/.history/weather_20251025173927.py @@ -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") + + diff --git a/weather/.history/weather_20251025173930.py b/weather/.history/weather_20251025173930.py new file mode 100644 index 0000000..1f532bf --- /dev/null +++ b/weather/.history/weather_20251025173930.py @@ -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") + + diff --git a/weather/.history/weather_20251025173938.py b/weather/.history/weather_20251025173938.py new file mode 100644 index 0000000..1f532bf --- /dev/null +++ b/weather/.history/weather_20251025173938.py @@ -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") + + diff --git a/weather/.history/weather_20251025173940.py b/weather/.history/weather_20251025173940.py new file mode 100644 index 0000000..1f532bf --- /dev/null +++ b/weather/.history/weather_20251025173940.py @@ -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") + + diff --git a/weather/weather.py b/weather/weather.py index 75fd2f6..1f532bf 100644 --- a/weather/weather.py +++ b/weather/weather.py @@ -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") + +