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 :-
NPTEL Social Networks Assignment Answer week 1 2023
1. If there exist a graph where nodes represents students and edges represents friendship, then for a rumour to be spread across entire class –
- Every student must know every other student.
- The graph needs to be connected.
- The graph need not be connected.
- Will spread in any case.
Answer :- The graph needs to be connected.
2. If x = random.randrange(5,10), which values can x take?
- I) 5
- II) 8
- III) 4
- IV) 10
- Only I, II
- Only I, III
- Only I, III, IV
- Only I
Answer :- only i , ii
3. If x = random.randint(3,6), which values can x take?
I) 5
II) 4.3
III) 3
IV) 6
- Only I, II
- Only I, III
- Only I, III, IV
- Only I
Answer :- Only I, III, IV
4. What will be the output of the following code snippet?
x = [5, 2, 7, 3, 8]
try:
a = x[5]
if(a%2 == 0):
print(“It is an even number”)
else:
print(“It is an odd number”)
except:
print(“Element does not exist”)
- It is an even number
- It is an odd number
- Element does not exist
- The code won’t run
Answer :- Element does not exist
5. What will be the output of the following code snippet?
import random
x = []
for i in range(7):
x.append(random.randint(1,5))
x.sort()
x.append({“one”:1, “two”:2})
print(len(x))
- 9
- 8
- 7
- 10
Answer :- 8
6. Maximum number of edges that can be present in a graph with 10 nodes are –
- 100
- 45
- 50
- 55
Answer :- 45
7. For a complete graph Z with 5 nodes if A=z.order()/z.size(), what will be the value of A?
- 1/4
- 1/8
- 1/2
- 1/16
Answer :- 1/2
8. What will nx.dijktra_path(G,u,v) return?
- Returns shortest path from u to v in a weighted graph
- Returns shortest path length
- Returns all possible paths from u to v
- Returns no. of possible paths from u to v
Answer :- Returns shortest path from u to v in a weighted graph
9. What will nx.gnp_random_graph(20,0.5) return?
- Returns graph with 20 nodes with half of the nodes connected.
- Returns graph with 20 nodes with each edge to be put with probability 0.5
- Returns a connected graph with 10 nodes.
- Returns a graph with 10 nodes with each edge to be put with probability 0.5
Answer :- Returns graph with 20 nodes with each edge to be put with probability 0.5
10. Maximum number of graphs possible from 50 nodes are –
- 50∗50
- 2(50/2)
- 50/2
- 5050
Answer :- 2(50/2)
NPTEL Social Networks Assignment Answer week 2 2023
1. For graph G, what will the following code snippet return?
values = nx.degree(G).values()
x =0
for value in values:
if(x<value):
x = value
return x
- Returns the number of nodes with the minimum degree.
- Returns the number of nodes with the maximum degree.
- Returns the minimum degree of the graph.
- Returns the maximum degree of the graph.
Answer :- Returns the maximum degree of the graph.
2.
The density of the given graph above is?
- 4/3
- 2/3
- 1/3
- 3/4
Answer :- 2/3
3. For the given graph, If A=Highest degree/∑degree, what will be the value of A?
- 3/5
- 2/5
- 2/15
- 3/10
Answer :- 3/10
4. Which of the following is an example of a Directed graph?
I. Network of Instagram followers
II. Ancestral Tree
III. Email network
IV. Road network
- Only IV
- Only I, II
- Only II, III
- Only I, II, III
Answer :- Only I, II, III
5.If X=clustering coefficient of node Eclustering coefficient of nodeF𝑋=𝑐𝑙𝑢𝑠𝑡𝑒𝑟𝑖𝑛𝑔 𝑐𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡 𝑜𝑓 𝑛𝑜𝑑𝑒 𝐸𝑐𝑙𝑢𝑠𝑡𝑒𝑟𝑖𝑛𝑔 𝑐𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡 𝑜𝑓 𝑛𝑜𝑑𝑒𝐹 in the given graph, the value of X is ___.
- 1
- 1/3
- 1/9
- 2/3
Answer :- 1/3
6. Which of the following is/are network dataset format?
I. GraphML
II. Pajek NET
III. Comma Separated Value(Edge List format)
- Only II
- Only III
- Only I, III
- Only I, II, III
Answer :- Only I, II, III
7. In graph G, where nodes represent words in a dictionary and there is an edge between two nodes if the two words are synonymous. Then, choose the correct option according to the given two statements.
Statement I: The graph G is connected.
Statement II: If the word A is connected to B & B is connected to C, then A is synonymous to C.
- Both statements are incorrect.
- Statement I is incorrect & Statement II is correct.
- Statement I is correct & Statement II is incorrect.
- Both statements are correct.
Answer :- Statement I is correct & Statement II is incorrect.
8. The diameter of the given graph G is ___.
- 5
- 4
- 3
- 2
Answer :- 4
9. If there exist 𝑛 nodes with no edges initially then, what is the probability of node V being isolated after including 𝑛𝑙𝑜𝑔(𝑛) edges uniformly at random?
- 1/e
- 1/nlog(n)
- 1/n
- 1/n2
Answer :- 1/n2
10. Choose the data set format which starts with the keyword “graph”?
- GML
- Graph Exchange XML
- Pajek Net format
- GEXF
Answer :- GML