I worked on the friends functions and the weather.

Checkpoint 1: I kind of hated how the test_friend_functions worked.
It was overstimulating and I had to move my friend_functions code into
the people code to test them out. I did end up getting correct results
for the functions that I created but I couldm't figure out what was
happening to these results when I ran them with test_friend_functions
instead. I took too much time getting frustrated on this part so I
decided to move on after thinking that I got the general gist of it.
I also talked to Molly and we both thought this part was frustrating and
moved on after a while.

Checkpoint 2: This part of the lab was less frustrating than the one
before. I guess understanding what the weather API did helped a lot as well
as the practice from frined functions to call things appropriately.
My general understanding of what all these systems have in common is that
they all rely on inputs one way or the other. For more complex systems such
as the weather that draws from online data, we also have to be careful with
how to integrate and recall outputs to continue and then categorize them
as we need.
This commit is contained in:
caglazir
2025-10-25 17:39:49 -04:00
parent 7e636f6b67
commit 581f77b463
50 changed files with 2068 additions and 55 deletions

View File

@@ -10,64 +10,46 @@
# 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()
count=0
for person in people:
if "name" in person:
count=count+1
print(count)
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()
email=""
for person in people:
if person["name"] == name:
email=person["email"]
print(f'"{email}"')
return
else:
print("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.
for person in people:
if person["name"] == name:
numcolor=len(person["favorite_colors"])
print(numcolor)
return
else:
print("None")
>>> count_favorite_colors(family, "Tad Winters")
2
>>> count_favorite_colors(family, "Raphael Chambers")
1
"""
raise NotImplementedError()
def people_who_like_color(people, color):
"""Returns a list containing only those people who like the given color.
>>> people_who_like_color(family, "yellow")
[
{
"name": "Walker Hurley",
"email": "auctor.odio@icloud.ca",
"favorite_colors": ["red", "yellow", "blue", "orange"],
},
{
"name": "Clementine Joseph",
"email": "hendrerit@aol.co.uk",
"favorite_colors": ["yellow", "aqua", "black"],
}
]
>>> people_who_like_color(family, "indigo")
[]
"""
raise NotImplementedError()
for person in people:
if color in person["favorite_colors"]:
print(person)
else:
print([])
def count_people_who_like_color(people, color):
"""Returns the number of people who like a given color.
>>> count_people_who_like_color(family, "red")
2
>>> count_people_who_like_color(family, "orange")
1
"""
raise NotImplementedError()
colorcount=0
for person in people:
if color in person["favorite_colors"]:
colorcount=colorcount+1
print(colorcount)
def get_color_dict(people):
"""Returns a dict showing how many people like each color.