Created command line weather forecast.

All of these systems use lists and dictionaries for keeping track of
positional and symbolic arguments.
This commit is contained in:
tgaeta
2025-10-08 14:15:16 -04:00
parent 8f4fb6a4d9
commit 2c8f2ff2c0
3 changed files with 17 additions and 1 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
weather/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -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 metric is True, prints out the weather in metric units.
When verbose is True, prints out a more detailed report. 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"]}.")