Repositories रिकमेंड करें
आप लगभग अंत तक पहुँच चुके हैं! यहाँ आपका काम set difference का अभ्यास करना है, और आप इसे दूसरे यूज़र के repositories रिकमेंड करने में लागू करेंगे जिनमें पहले यूज़र को योगदान देना चाहिए.
यह अभ्यास पाठ्यक्रम का हिस्सा है
इंटरमीडिएट Network Analysis in Python
अभ्यास निर्देश
recommend_repositories()नाम का एक फंक्शन लिखें जो 3 आर्ग्युमेंट लेता है —G,from_user, औरto_user— और वे repositories लौटाता है जिनसेfrom_userजुड़ा है लेकिनto_userनहीं जुड़ा है.- जिन repositories में
from_userने योगदान दिया है, उनका set लीजिए और उसेfrom_reposके रूप में स्टोर कीजिए. इसके लिए पहलेfrom_userके neighbors निकालें और उस परset()फंक्शन लगाएँ. - जिन repositories में
to_userने योगदान दिया है, उनका set लीजिए और उसेto_reposके रूप में स्टोर कीजिए. .difference()मेथड का उपयोग करके वे repositories रिटर्न कीजिए जिनसेfrom_userजुड़ा है लेकिनto_userनहीं जुड़ा है.
- जिन repositories में
- जिन repositories को रिकमेंड करना है उन्हें from
'u7909'to'u2148'प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
def ____:
# Get the set of repositories that from_user has contributed to
from_repos = ____
# Get the set of repositories that to_user has contributed to
to_repos = ____
# Identify repositories that the from_user is connected to that the to_user is not connected to
return ____.____(____)
# Print the repositories to be recommended
print(____)