diff --git a/friend_functions.py b/friend_functions.py index 6f5ecf7..b1d6d0c 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -17,7 +17,7 @@ def count_people(people): >>> count_people(friends) 10 """ - raise NotImplementedError() + return len(people) def get_email(people, name): """Returns the named person's email address. If there is no such person, returns None. @@ -27,7 +27,10 @@ def get_email(people, name): >>> get_email(friends, "Tad Winters") None """ - raise NotImplementedError() + for person in people: + if person["name"] == name: + return person["email"] + return 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. @@ -37,7 +40,10 @@ def count_favorite_colors(people, name): >>> count_favorite_colors(family, "Raphael Chambers") 1 """ - raise NotImplementedError() + for person in people: + if person["name"] == name: + return len(person["favorite_colors"]) + return None def people_who_like_color(people, color): """Returns a list containing only those people who like the given color. @@ -57,7 +63,10 @@ def people_who_like_color(people, color): >>> people_who_like_color(family, "indigo") [] """ - raise NotImplementedError() + for person in people: + if person["favorite_colors"] == color: + return people + return None def count_people_who_like_color(people, color): """Returns the number of people who like a given color. @@ -67,7 +76,9 @@ def count_people_who_like_color(people, color): >>> count_people_who_like_color(family, "orange") 1 """ - raise NotImplementedError() + for person in people: + if person["favorite_colors"] == color: + return len(people) def get_color_dict(people): """Returns a dict showing how many people like each color. diff --git a/weather/weather.py b/weather/weather.py index 75fd2f6..268a2bb 100644 --- a/weather/weather.py +++ b/weather/weather.py @@ -21,4 +21,15 @@ 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! + if location: + coordinates = geocode_location(location) + else: + coordinates = estimate_location() + + office = get_weather_office(coordinates["lat"], coordinates["lng"]) + + forecast = get_forecast(office["office"], office["x"], office["y"], metric=metric) + + for day in forecast: + display = day["name"] + " Temperature: " + str(day["temperature"]) + " Wind Speed: " + str(day["wind_speed"]) + " Weather: " + day["description"] + print(display) \ No newline at end of file