View the step-by-step solution to:

Question

plz help me for at least recommend clubs based off the dictonary P2F and P2C


src="/qa/attachment/10935391/" alt="question recommend.png" />question friends.pngdata.pngrecommend_clubs.pnggetcluboffriends.png

data.png

getcluboffriends.png

def get clubs of friends (person to friends: Dict [str, List[str]],
person to clubs: Dict [str, List [str]],
person: str) -> List [str] :
""Return a list, sorted in alphabetical order, of the clubs in
person to clubs that person's friends from person to friends
belong to, excluding the clubs that person belongs to.
Each club
appears in the returned list once per each of the person's friends
who belong to it.
> > get clubs of friends (P2F, P2C, 'Danny R Tanner' )
['Comics R Us', ' Rock N Rollers' ]
pass
# Remove me when you've implemented this function

question friends.png

The first parameter represents a "person to friends" dictionary, the second parameter represents a "person to clubs"
dictionary, and the third parameter represents the name of a person (in the same format as the dictionary keys). The function
get7(1ubsiofifriends : should return a list of clubs to which the given person‘s friends are members of. The returned list should be sorted in
(Dict[str. List[str]]. Dictlstr, List[str]]. alphabetical order. The list should not contain clubs that the given person is a member of. The clubs should appear in the
str) —> List[5‘tr] returned list once for each of the person's friends that are members of it. (That is, clubs may be included more than once in
the returned list.) Use the list method sort to put the clubs into alphabetical order.

question recommend.png

recommendiclubs:
(Di(t[str, List[str]], Di(t[str, List[str]],
str) ,> List[TuplE[str, int]] The first parameter represents a "person to friends" dictionary, the second parameter represents a l‘person to clubs'r
dictionary, and the third parameter represents a person's name (in the same format as the dictionary keys). Using the
recommendation system described below, the function should return the club recommendations for the given person as a list
of 2—element tuples. The first element of each tuple is a potential club's name (in the same format as the dictionary keys) and
the second element is that potential club‘s score. Only potential clubs with nonszero scores should be included in the list. The
recommendations should be sorted from highest to lowest score. If multiple clubs have the same score, they should be sorted
alphabetically (by the clubs' names). The person given as the first argument may be a key in zero, one, or both of the given dictionaries.
Recommendation score Imagine that a person wants to get recommendations for potential clubs — clubs they are not a member of but may wish to
join. The social network calculates a recommendation score for each potential club. For a particular person, each potential club starts out with a score of [J and is scored using the following point system: . Add 1 point to the potential club's score for each of the person's friends who are members of the potential club.
- Add 1 point for every member of the potential club, who is in at least one different club with the person. Examples (refer to the diagram below, which represents the data in P2P and P2C in the starter code): Cit-rmrzzfi @3 ,_ _i_ //_i 5....“ i (mm when making recommendations for Jesse Katsopolis, the result is: [('Comics R Us', 2), {'Smash Club', 1)] - Comics R Us gets one point because Jesse Katsopolis's friend Joey Gladstone is a member of Comics R Us. - Comics R Us gets a second point because Joey is a member of Comics R Us and both Jesse and Joey are members of
Parent Council. - Smash Club gets one point because Kimmy is a member of Smash Club and Kimmy is in a different club (Rock N Rollers)
with Jesse. When making recommendations for Stephanie J Tanner, the result is: [('Comet Club', 1), ('Rock N Rollers', 1), ('Smash Club', 1}] . Comet Club gets one point because Stephanie's friend Michelle Tanner is a member of Comet Club.
- Smash Club gets one point because Stephanie's friend Kimmy Gibbler is a member of Smash Club.
- Rock N Rollers gets one point because Stephanie's friend Kimmy Gibbler is a member of Rock N Rollers. Hint: There are two ways a potential club's score can increase. Consider creating a helper function for each way.

recommend_clubs.png

def recommend clubs (
person to friends: Dict[str, List[str]],
person to clubs: Dict [str, List[str]],
person: str, ) -> List [Tuple [str, int]]:
""Return a list of club recommendations for person based on the
"person to friends" dictionary person to friends and the "person
to clubs" dictionary person to clubs using the specified
recommendation system.
>>> recommend clubs (P2F, P20, 'Stephanie J Tanner' , )
[ ( 'Comet Club', 1), ('Rock N Rollers', 1), ('Stamp Club', 1) ]
pass
# Remove me when you've implemented this function

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes