From 2c8f2ff2c08b6990a60704482d2586ed70b83052 Mon Sep 17 00:00:00 2001 From: tgaeta Date: Wed, 8 Oct 2025 14:15:16 -0400 Subject: [PATCH] Created command line weather forecast. All of these systems use lists and dictionaries for keeping track of positional and symbolic arguments. --- .DS_Store | Bin 6148 -> 6148 bytes weather/.DS_Store | Bin 0 -> 6148 bytes weather/weather.py | 18 +++++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 weather/.DS_Store diff --git a/.DS_Store b/.DS_Store index 6e2b1678680eb39fcb52b157b0246b23f4dc9287..8d2981c362b251a54ad43d2cfd93a38ccc9a11b3 100644 GIT binary patch delta 162 zcmZoMXffEJ$`sGY-o(Jbz`~%%kj{|FP?DSP;*yk;p9B=+P}1Apk>!2d5mi0~uY5s< zVQ_MOZUIma&{PA4$?KS;CeLHq#^^P9A+zx03}zm-w(QkUa=a%mU>2F&hs;%CoUr*K Pvl+|80=~`c9Dn%%=$$P1 delta 159 zcmZoMXffEJ$`sG=cQyk90}F#5LpnnyLrHGFi%U{YeiBfOklo65X(WMJBo&dSTXlP9h?dXB(kwAZON^+kf z+nRbhBKME{>-KTJYPx-|XeEd41C_UvJM@Z%@|Cba-jcTKBup zSww_&aR!_LXTTY727bf zoXP!vhhJv2$RE1+$Qf`3{uu*2NvpKLrtEJ0vOT$L1KK^Bh}dOOAkYVo01V_Dxhjjg b9z=&-G|Y+;Mdph;&>sSY5bvCUUtr)39N{tu literal 0 HcmV?d00001 diff --git a/weather/weather.py b/weather/weather.py index 75fd2f6..3dd12a8 100644 --- a/weather/weather.py +++ b/weather/weather.py @@ -21,4 +21,20 @@ def print_weather(location=None, metric=False, verbose=False): 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! + + coords = estimate_location() if location is None else geocode_location(location) + if not coords: + return print("Cannot determine location.") + + office = get_weather_office(**coords) + if not office: + return print("Cannot determine NWS office.") + + weather = get_forecast(**(office | {'metric': metric})) + if not weather: + return print("Forecast cannot be found.") + + print(f"Today will be {weather[0]["description"].lower()} with an average temperature of {weather[0]["temperature"]}°{"C" if metric else "F"}.") + if verbose: + print(f"Winds headed {weather[0]["wind_direction"]} at {weather[0]["wind_speed"]}.") +