NPTEL Social Networks Week 1 Assignment Answers 2025
1. Which Python code correctly computes the sum of even numbers in the list L = [3, 5, 8, 2, 6] ?
- sum([x for x in L if x % 2 == 0])
- sum([x for x in L if x % 2 != 0])
- sum([x for x in L if x > 2])
- sum(L)
Answer :- For Answer Click Here
2. You are given a dictionary d = {‘A’: 10, ‘B’: 20, ‘C’: 30} . Which Python code snippet correctly adds a new key D with value 40 to the dictionary?
- d[‘D’] = 40
- d.add(‘D’, 40)
- d.update(‘D’, 40)
- d.append({‘D’: 40})
Answer :-
3. Given the following Python code snippet, what will be the output?
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 4, 9, 16]
plt.plot(x, y)
plt.show()
- A bar chart displaying the values in x and y .
- A line graph connecting the points (1,1), (2,4), (3,9), (4,16) .
- A scatter plot with points (1,1), (2,4), (3,9), (4,16) .
- A histogram displaying the values of x and y .
Answer :-
4. Using the NetworkX library, how would you create an undirected graph with three nodes ( A , B , C ) and two edges ( A-B and B-C )?
- G = nx.Graph()
G.add_edges_from([(‘A’, ‘B’), (‘B’, ‘C’)]) - G = nx.DiGraph()
G.add_edges_from([(‘A’, ‘B’), (‘B’, ‘C’)]) - G = nx.Graph()
G.add_nodes_from([‘A’, ‘B’, ‘C’]) - G = nx.Graph()
G.add_edges_from([(‘A’, ‘B’), (‘B’, ‘C’)], directed=True)
Answer :-
5. In the PageRank algorithm, what is the primary assumption regarding the link structure of the web?
- Pages that are linked to more often are likely more important.
- Pages that are less frequently linked are likely more important.
- Pages with more content are likely more important.
- Pages without links are considered equally important as those with links.
Answer :-
6. In a social network, you are tasked with finding the shortest path between two individuals, A and B . Which of the following algorithms would be most suitable?
- Dijkstra’s Algorithm
- A* Search Algorithm
- Breadth-First Search (BFS)
- Depth-First Search (DFS)
Answer :- For Answer Click Here
7. Which of the following methods is commonly used for link prediction in a social network?
- Collaborative Filtering
- K-means Clustering
- Matrix Factorization
- Jaccard Similarity Index
Answer :-
8. In models of contagion in social networks, what does the term “threshold” specifically refer to?
- The minimum number of links required to spread an infection in a network.
- The fraction of neighbors a node needs to be influenced by to adopt a new behavior.
- The time it takes for an infection to spread from one node to another.
- The maximum number of nodes that can be infected at any given time.
Answer :-
9. Which centrality measure would you use to find the individuals who have the shortest average path length to all other nodes in the network?
- Degree Centrality
- Closeness Centrality
- Betweenness Centrality
- Eigenvector Centrality
Answer :-
10. Which of the following NetworkX functions can be used to predict potential links in a network based on node similarity indices?
- nx.resource_allocation_index(G)
- nx.shortest_path_length(G)
- nx.closeness_centrality(G)
- nx.betweenness_centrality(G)
Answer :- For Answer Click Here