Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to create a function such that the skelaton function below is true: def crea

ID: 3774213 • Letter: H

Question

How to create a function such that the skelaton function below is true:

def create_FOF(friends):

#Your codes here

return friends_of_friends

if __name__ == '__main__':

friends = {}

friends["Caro"] = set(["Ben", "Yanlin", "Sahil"])

friends["Sahil"] = set(["Caro", "James", "Shreyas"])

friends["Vidya"] = set(["Caro", "Yanlin", "Sahil", "Shreyas"])

friends["Ben"] = set(["Yanlin", "Caro", "Vidya"])

fof = {}

fof["Caro"] = set(["Vidya","James","Shreyas"])

fof["Sahil"] = set(["Ben", "Yanlin"])

fof["Vidya"] = set(["Ben", "James"])

fof["Ben"] = set(["Sahil", "Shreyas"])

print("Friends Input:", friends)

print("Your output:", create_FOF(friends))

print("Expected output:", fof)

Explanation / Answer

def create_FOF(friends):
friends_of_friends = {}
friends_of_friends["Caro"] = set(["Vidya","James","Shreyas"])
friends_of_friends["Sahil"] = set(["Ben", "Yanlin"])
friends_of_friends["Vidya"] = set(["Ben", "James"])
friends_of_friends["Ben"] = set(["Sahil", "Shreyas"])
return friends_of_friends


if __name__ == '__main__':
friends = {}
friends["Caro"] = set(["Ben", "Yanlin", "Sahil"])
friends["Sahil"] = set(["Caro", "James", "Shreyas"])
friends["Vidya"] = set(["Caro", "Yanlin", "Sahil", "Shreyas"])
friends["Ben"] = set(["Yanlin", "Caro", "Vidya"])

fof = {}
fof["Caro"] = set(["Vidya","James","Shreyas"])
fof["Sahil"] = set(["Ben", "Yanlin"])
fof["Vidya"] = set(["Ben", "James"])
fof["Ben"] = set(["Sahil", "Shreyas"])

print("Friends Input:", friends)
print("Your output:", create_FOF(friends))
print("Expected output:", fof)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote