From 291398cae9bfb16f9f00922454bbc99aca99a46c Mon Sep 17 00:00:00 2001 From: Hope Date: Mon, 7 Jul 2025 19:41:56 -0400 Subject: [PATCH 1/6] completed the count funtion --- friend_functions.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/friend_functions.py b/friend_functions.py index 6f5ecf7..3318094 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -10,14 +10,10 @@ # each and instead write code which returns the expected values. def count_people(people): - """Counts the number of people. - - >>> count_people(family) - 5 - >>> count_people(friends) - 10 - """ - raise NotImplementedError() + #Counts the number of people in the list/dict sent + count = len(people) + return count + def get_email(people, name): """Returns the named person's email address. If there is no such person, returns None. From 8d781af4612a26e0b36b9ca7d33d6b23f943e178 Mon Sep 17 00:00:00 2001 From: Hope Date: Mon, 7 Jul 2025 19:57:18 -0400 Subject: [PATCH 2/6] completed the email function --- friend_functions.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/friend_functions.py b/friend_functions.py index 3318094..b7cc1c0 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -16,14 +16,11 @@ def count_people(people): def get_email(people, name): - """Returns the named person's email address. If there is no such person, returns None. - - >>> get_email(family, "Tad Winters") - "ligula.aenean@hotmail.edu" - >>> get_email(friends, "Tad Winters") - None - """ - raise NotImplementedError() + #Returns the named person's email address. If there is no such person, returns None. + for person in people: + if person.get("name") == name: + return person.get("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. From 47d2723a0a5aa8c606d1982949f813f220364605 Mon Sep 17 00:00:00 2001 From: Hope Date: Mon, 7 Jul 2025 20:14:28 -0400 Subject: [PATCH 3/6] completed the favorite colors count function --- friend_functions.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/friend_functions.py b/friend_functions.py index b7cc1c0..f68cdbe 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -30,7 +30,11 @@ def count_favorite_colors(people, name): >>> count_favorite_colors(family, "Raphael Chambers") 1 """ - raise NotImplementedError() + for person in people: + if person.get("name") == name: + fav_colors = len(person.get("favorite_colors")) + return fav_colors + return None def people_who_like_color(people, color): """Returns a list containing only those people who like the given color. From 847c416f3a32040908c188dfdc70ff759dbf568d Mon Sep 17 00:00:00 2001 From: Hope Date: Mon, 7 Jul 2025 20:45:48 -0400 Subject: [PATCH 4/6] completed the list of people who like a color and the number or people who like a color functions. --- friend_functions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/friend_functions.py b/friend_functions.py index f68cdbe..20653e4 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -54,7 +54,8 @@ def people_who_like_color(people, color): >>> people_who_like_color(family, "indigo") [] """ - raise NotImplementedError() + return [person for person in people if color in person.get("favorite_colors", [])] + def count_people_who_like_color(people, color): """Returns the number of people who like a given color. @@ -64,7 +65,7 @@ def count_people_who_like_color(people, color): >>> count_people_who_like_color(family, "orange") 1 """ - raise NotImplementedError() + return len(people_who_like_color(people,color)) def get_color_dict(people): """Returns a dict showing how many people like each color. From f8a089f6e60aba10ab54a61cd57bcb2a2d75e001 Mon Sep 17 00:00:00 2001 From: Hope Date: Mon, 7 Jul 2025 21:07:00 -0400 Subject: [PATCH 5/6] completed the last function. I had to use AI for help on syntax for adding to a count. --- friend_functions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/friend_functions.py b/friend_functions.py index 20653e4..e207daf 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -84,7 +84,14 @@ def get_color_dict(people): "orange": 1, } """ - raise NotImplementedError() + fav_color_dict = {} + for person in people: + for color in person.get("favorite_colors", []): + if color in fav_color_dict: + fav_color_dict[color] += 1 + else: + fav_color_dict[color] = 1 + return fav_color_dict From 526ba2f5a92e108533ce0995808806ceb6d08c3a Mon Sep 17 00:00:00 2001 From: Hope Date: Mon, 7 Jul 2025 23:02:48 -0400 Subject: [PATCH 6/6] I am stuck at the very start. I don't know how to "run weather". --- people.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/people.py b/people.py index 68ea27e..ff04d4e 100644 --- a/people.py +++ b/people.py @@ -36,7 +36,7 @@ family = [ friends = [ { - "name": "Connor Rodriguez", + "name": "Connor Rodriguez", "email": "maecenas@yahoo.edu", "favorite_colors": ["aqua", "teal", "sea foam", "turquoise"], },