generated from mwc/lab_weather
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:
BIN
weather/.DS_Store
vendored
Normal file
BIN
weather/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -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"]}.")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user