From 6fd2c1c876673d953bc2529813a06545eeeb5809 Mon Sep 17 00:00:00 2001 From: Chris Mekelburg Date: Tue, 22 Oct 2024 21:26:19 -0400 Subject: [PATCH] Checkpoint 2 All 3 systems (functions, programs, and distributed services) all rely on taking arguments/inputs (whether simple or complex) and passing them through computer code to give some type of output. Also each level relies on the previous level, so programs contain functions, and distributed services contain programs which contain unctions. The biggest difference is the scale on which they are used, functions being the smallest and distributed services being the largest. --- weather/weather.py | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/weather/weather.py b/weather/weather.py index a2d74df..97fad32 100644 --- a/weather/weather.py +++ b/weather/weather.py @@ -25,23 +25,35 @@ def print_weather(location=None, metric=False, verbose=False): coordinates = estimate_location() else: coordinates = geocode_location(location) - print(coordinates) - #if coordinates == None: - # print("Location Unknown, Try Again") + #print(coordinates) #test/debug only + if coordinates == None: + print("Location Unknown, Try Again") + else: + + - office_info = get_weather_office(coordinates["lat"], coordinates["lng"]) - office_only = office_info["office"] + office_info = get_weather_office(coordinates["lat"], coordinates["lng"]) + #print(office_info) #test/debug only - all_forecasts = get_forecast(office_info["office"], office_info["x"], office_info["y"], metric) - print("The forecast for", office_only, "is") - if verbose==False: - simple_forecast = all_forecasts[0] - print(simple_forecast["name"],"temperature of", simple_forecast["temperature"], "wind speed of", simple_forecast["wind_speed"], "out of the ", simple_forecast["wind_direction"],"conditions of", simple_forecast["description"]) - print() - else: - for forecast in all_forecasts: - print(forecast["name"],"temperature of", forecast["temperature"], "wind speed of", forecast["wind_speed"], "out of the ", forecast["wind_direction"],"conditions of", forecast["description"]) - print() + if office_info == None: + print("Loooks like that location is not in the US. Try again") + pass + else: + office_only = office_info["office"] + all_forecasts = get_forecast(office_info["office"], office_info["x"], office_info["y"], metric) + if all_forecasts == None: + print("Unable to provide forecast for that location. Try another location.") + pass + else: + print("The forecast for", office_only, "is") + if verbose==False: + simple_forecast = all_forecasts[0] + print(simple_forecast["name"],"temperature of", simple_forecast["temperature"], "wind speed of", simple_forecast["wind_speed"], "out of the ", simple_forecast["wind_direction"],"conditions of", simple_forecast["description"]) + print() + else: + for forecast in all_forecasts: + print(forecast["name"],"temperature of", forecast["temperature"], "wind speed of", forecast["wind_speed"], "out of the ", forecast["wind_direction"],"conditions of", forecast["description"]) + print()