NPTEL Social Networks Week 1 Assignment Answers 2024
NPTEL Social Networks Week 1 Assignment Answers 2024
1. What will be the output of the following snippet of code?
print(" a + 'b' + c + ' ' + d ")
- a + “b” + c + ‘ ‘ + d
- “a + ‘b’ + c + ‘ ‘ + d”
- a + ‘b’ + c + ‘ ‘ + d
- a + “b” + c + ‘ ‘ + d
Answer :- For Answer Click Here
2. Which of the following are valid names for variables in Python?
- python_
- _python
- 1python
- I python
- I_python
Answer :-
Answer :- For Answer Click Here
Answer :-
- Output = [1, 3, -1, 4, -2, 5, 3]
- Output = [1, 3, 0, 4, 0, 5, 3]
- Output = [1, 3, -1, 4, -2, 5, 3, 0, 0, 0]
- Output = [1, 0, -1, 0, -2, 0, 3]
- Output = [0, 3, 0, 4, 0, 5, 0]
- This code is wrong
Answer :- For Answer Click Here
Answer :-
7. Farhat has a list of topper students and he wants to select a student randomly from the list to enlist in a top secret project he is working on. Help Farhat choose the function which can help him do it.
- random.sample(students,1)
- random.choice(students)
- random.choices(students)
- random.randint(0, len(students) – 1)
- None of the above
Answer :- For Answer Click Here
8. Gogo has created a list of connections in his classroom. Each connection is represented as a tuple of two individuals who are friends. Gogo needs to create an undirected graph and find the number of nodes and edges in the graph.
Connections = [(‘Jagirat’,’Jatin’), (‘Jagirat’, ‘Ashutosh’), (‘Jatin’, ‘Gitansh’), (‘Ashutosh’,’Gitansh’), (‘Gitansh’,’Nishit’)]
import networkx as nx
def class_network(Connections):
G = nx.graph()
G.add_edges_from(Connections)
num_nodes = G.number_of_nodes()
num_edges = G.number_of_edges()
return num_nodes, num_edges
print(class_network(Connections))
- (4,5)
- (5,4)
- (5,6)
- (6,5)
- (5,5)
- (4,4)
- (6,6)
- (4,6)
Answer :-
9. Aashik wants to create a random graph with 10 nodes with the probability of an edge being present as 0.35. Which function can he choose?
- nx.random_graph(10,0.35)
- nx.gnp_random_graph(10,0.35)
- nx.erdos_renyi_graph(10,0.35)
- Both (b) and (c)
Answer :- For Answer Click Here
10. Aashik now wants to create a directed graph and add edges to it. Help Aashik with choosing the right function.
- nx.graph() & graph.add_edge()
- nx.Digraph() & graph.add_edge()
- nx.Multigraph() & graph.add_edge_from()
- nx.MultiDigraph() & graph.add edges_from()
Answer :-
11. Now, Aashik wants to see the graph he has created, Which of the folllowing options can help him with it?
- nx.draw(graph) & plt.show()
- nx.plot(graph) & plt.show()
- nx.display(graph)
- nx.draw(graph) & plt.visualize()
Answer :-
12. Aashik wants to check if the first random graph he created was connected or not. Which function will he use now?
- nx.is_connected(graph)
- nx.connected(graph)
- nx.isconnected(graph)
- nx.is_fully_connected(graph)
- nx.is_complete(graph)
Answer :-
13. Ashutosh created a social network graph of his class and wants to find out who is the person he can be friends with very easily. Which algorithmic concept can he use to do this?
- Page Ranking
- BFS
- DFS
- Link Prediction
Answer :-
14. Sundari has 55 students in his class and he wants to create a network graph for the class. What is the maximum number of graphs possible for the given class.
- 255
- 55C2
- 255C2
- 552
Answer :-