शुरू करेंमुफ़्त में शुरू करें

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 को रिकमेंड करना है उन्हें 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(____)
कोड संपादित करें और चलाएँ