Social Networks | Week 1
Session: JULY-DEC 2023
Course Name: Social Networks
Course Link: Click Here
These are Nptel Social Networks Week 1 Assignment 1 Answers
Q1. Which function will you use to find the number of edges drawn in the Graph?
order( )
edges( )
edge_size( )
number_of_edges( )
Answer: number_of_edges( )
Q2. What will be the maximum number of edges for a graph with 10 vertices?
10
45
55
100
Answer: 45
Q3. What does items() function for a dictionary return?
Dictionary with all keys and values
List with tuples having keys and values
List containing all keys and values
Tuples containing all keys and values
Answer: List with tuples having keys and values
These are Nptel Social Networks Week 1 Assignment 1 Answers
Q4. What will be the output of the given code?
x=[i for i in range(10)]
plt.plot(x,x**2,‘r=’)
plt.show ( )
Error displaying unsupported operand types for ** in plot
It plots the x with its exponential value with points and lines in the plot
It plots x with expontential value with points in the plot
It plots x with expontential value with red line in the plot
Answer: Error displaying unsupported operand types for ** in plot
Q5. What does the value ‘ys-’ as the third parameter in plot function indicate?
It helps to plot square with line connecting the points
It helps to plot yellow color square with dotted line connecting the points
It helps to plot yellow color square with line connecting the points
It helps to plot yellow color dotted line
Answer: It helps to plot yellow color square with line connecting the points
Q6. Choose the correct statement to convert a list ‘List1’ to array in numpy.
List1.numpy()
List1.numpy array()
List1=numpy.array(List1)
List1.numpy.array()
Answer: List1=numpy.array(List1)
These are Nptel Social Networks Week 1 Assignment 1 Answers
Q7. Use networkx package, and write the statement to add the edges between two nodes (1,2) of a graph G=nx.Graph().
G.add_edge()
G.add_edge(1,2)
G.addedge(1,2)
G.AddEdge(1,2)
Answer: G.add_edge(1,2)
Q8. If you want to generate a random number from an inclusive range which function is to be used?
randrange()
randint()
random.random()
rand_Int()
Answer: randint()
Q9. If a=‘Social’, b=‘Networks’ then which of the following operation would show ’SocialNetworks’ as output?
a+b
a+”+b
a+””+b
All of the above
Answer: All of the above
These are Nptel Social Networks Week 1 Assignment 1 Answers
Q10. In the command networkx.erdos_renyi_graph(a,b), the parameters ‘a’ and ‘b’ denote the following respectively:
Number of edges and the probability with which edges are to be placed between every pair of nodes
Number of nodes and the probability with which edges are to be placed between every pair of nodes
The probability with which edges are to be placed between every pair of nodes and Number of edges
Number of edges and Number of nodes
Answer: Number of nodes and the probability with which edges are to be placed between every pair of nodes
These are Nptel Social Networks Week 1 Assignment 1 Answers
More Weeks of Social Networks: Click here
More Nptel Courses: Click here
Session: JAN-APR 2023
Course Name: Social Networks
Course Link: Click Here
These are Nptel Social Networks Week 1 Assignment 1 Answers
Q1) What would be the output for the following code?
scores=[78,77,45]
scores.append(90)
scores.append(98)
scores.reverse()
print(scores)
a. [98, 90, 78, 77, 45]
b. [78, 77, 45, 90, 98]
c. [98, 90, 45, 77, 78]
d. [78, 77, 45, 98, 90]
Answer: c. [98, 90, 45, 77, 78]
Q2) Given the following code, Which of the following is not a possible output?
import random
def calc():
x=random.random()
y=random.random()
z=random.random()
return( x+y+z )
print(calc())
a. 1.6115945523495627
b. 0.202709723169674
c. 2.3142203461882844
d. 3.9133426822720435
Answer: d. 3.9133426822720435
Q3) Which of the following statement creates the given dictionary, d:{1:1,2:4,3:9,4:16}
a. d={x:x∗∗2 for x in range(1,5)}
b. d={x:x∗∗2 for x in range(5)}
c. d={x:x∗∗2 for x in range(0,5)}
d. d={x:x∗∗2 for x in range(1,6)}
Answer: a. d={x:x∗∗2 for x in range(1,5)}
These are Nptel Social Networks Week 1 Assignment 1 Answers
Q4) Identify the graph output for the following segment:
import networkx as nx
import matplotlib.pyplot as plt
G=nx.Graph()
G.add_nodes_from([1,2,3,4,5])
G.add_edges_from([(1,2),(2,3),(2,5),(1,6),(3,4)])
nx.draw(G,with_labels=True)
plt.show()
Answer: a
These are Nptel Social Networks Week 1 Assignment 1 Answers
Q5) Given the following code, what is the number of edges in the graph created?
G=nx.Graph()
G.add_nodes_from([i for i in range(10)])
def create_graph(n):
while(len(G.edges())< n):
u=random.choice(list(G.nodes()))
v=random.choice(list(G.nodes()))
if u!=v and G.has_edge(u,v)==0:
G.add_edge(u,v)
a. 9
b. 10
c. n
d. n−1
Answer: c. n
Q6) Which of the statements is True for the graph created from the statement: nx.gnp_random_graph(10,0.5)?
a. Graph has 10 nodes with half of the nodes connected
b. Graph has 10 nodes with each edge to be put with probability 0.5
c. Connected graph with 10 nodes
d. Graph has 5 nodes with half of the nodes connected
Answer: b. Graph has 10 nodes with each edge to be put with probability 0.5
These are Nptel Social Networks Week 1 Assignment 1 Answers
Q7) What is the maximum number of graphs that can be created from 10 nodes?
a. 2(10 2)
b. 2(2 10)
c. 210
d. 210 2
Answer: a. 2(10 2)
Q8) Given that we have n nodes in a network, what is the approximate number of steps to search a node?
a. nlogn
b. logn
c. nn
d. 2logn
Answer: b. logn
These are Nptel Social Networks Week 1 Assignment 1 Answers
Q9) Identify the layout for the graph given in the following figure.
a. spectral
b. spring
c. circular
d. random
Answer: c. circular
Q10) Friend suggestion on Facebook is one of the applications of
a. Page ranking
b. Link prediction
c. Small work phenomenon
d. Cascading
Answer: b. Link prediction
These are Nptel Social Networks Week 1 Assignment 1 Answers
More Solutions of Social Networks: Click Here
More NPTEL Solutions: https://progiez.com/answers/nptel/