Hey!! How are you doing, the answers are ready! This Week NPTEL Joy Of Computing Using Python Week 12 Assignment 2025. All of the questions were solved and their proofs were. Also, the previous assignment of Week 11 Assignment is available now.
Also Read:Â NPTEL Joy Of Computing Using Python Week 11 Assignment 2025
Also Read:Â NPTEL Joy Of Computing Using Python Week 11 Assignment 2025
Join us on Telegram 👉 CLICK HERE Â
NPTEL Joy Of Computing Using Python Week 12 Assignment 2025
Last Date: 16-04-2025
Q1. Which of the following graphs is generated by the given Python code using the networkx module?
import networkx as nximport matplotlib.pyplot as pltG=nx.Graph()G.add_nodes_from([1, 2, 3, 4, 5])G.add_edges_from([(1, 2), (2, 3), (3, 4), (4, 5), (5, 1)])nx.draw(G, with_labels=True, node_color='lightblue',edge_color='gray', node_size=1000, font_size=16)plt.show() {codeBox}
The option 1 satisfies with number of edges and nodes.Â
In option 3, it also match with sufficient edges and nodes, it is circular. So the option is 1.
Q3. Observe the following graph generated using the networkx module. How many edges does this graph contain?
A. 6
B. 7
C. 8
D. 9
Answer: [ B ] 7
Q4. What does nx.cycle graph(4) generate?
Q5. Observe the following graph generated using the networkx module. What type of graph is this?
A. Ladder Graph
B. Barbell Graph
C. Wheel Graph
D. Star GraphÂ
Answer: [ B ] Barbell Graph
Q8. What will be the first 10 numbers generated starting from n = 7?
A. [7, 36, 18, 9, 46, 23, 116, 58, 29, 146]
B. [7, 36, 18, 9, 28, 14, 7, 36, 18, 9]
C. [7, 20, 10, 5, 26, 13, 66, 33, 166, 83]
D. [7, 31, 15, 7, 36, 18, 9, 46, 23, 116]
Answer: [ A ] [7, 36, 18, 9, 46, 23, 116, 58, 29, 146]Â
Q9. Which technique is used in the PageRank algorithm to determine the rank of a web page?
Q2. In networkX, which function is used to return the degree of a specific node?
A. G.degree(node)
B. G.get_degree(node)
C. G.node_degree(node)
D. G.find_degree(node)
Answer: [ A ]Â G.degree(node)
B. G.get_degree(node)
C. G.node_degree(node)
D. G.find_degree(node)
Answer: [ A ]Â G.degree(node)
Q3. Observe the following graph generated using the networkx module. How many edges does this graph contain?
B. 7
C. 8
D. 9
Answer: [ B ] 7
Q4. What does nx.cycle graph(4) generate?
A. A directed cycle of 4 nodes
B. A cycle graph with 4 nodes connected in a closed loop
C. A ladder graph with 4 rounds in the ladder
D. A complete graph with 4 nodes
Answer: [ B ] A cycle graph with 4 nodes connected in a closed loop
B. A cycle graph with 4 nodes connected in a closed loop
C. A ladder graph with 4 rounds in the ladder
D. A complete graph with 4 nodes
Answer: [ B ] A cycle graph with 4 nodes connected in a closed loop
Q5. Observe the following graph generated using the networkx module. What type of graph is this?
B. Barbell Graph
C. Wheel Graph
D. Star GraphÂ
Answer: [ B ] Barbell Graph
Barbell Graph:Â Two complete graphs connected by a path Â
Q6. What will be the output of the following code?
A. (4, 4)
B. (4, 8)
C. (4, 2)
D. (8, 4)
Answer: [ A ] (4, 4)
import networkx as nxÂG = nx.Graph()G.add_edges_from([(1, 2), (2, 3), (3, 4), (4, 1)])print(len(G.nodes()), len(G.edges())) {codeBox}
B. (4, 8)
C. (4, 2)
D. (8, 4)
Answer: [ A ] (4, 4)
Q7. What is the output of this code?
A. 7
B. 16
C. 5
D. 10
Â
Answer: [ B ] 16Â
def collatz_steps(n):Â Â steps=0Â Â while n!=1:Â Â Â Â n = n//2 if n%2 == 0 else 3 * n + 1Â Â Â Â steps += 1Â Â return stepsprint(collatz_steps(7)) {codeBox}
A. 7
B. 16
C. 5
D. 10
Â
Answer: [ B ] 16Â
Q8. What will be the first 10 numbers generated starting from n = 7?
def modified_collatz(n):Â Â sequence = [n]Â Â while len(sequence) < 10:Â Â Â Â if n%2 == 0:ÂÂ Â Â Â Â Â n = n//2Â Â Â Â else:Â Â Â Â Â Â n = 5*n+1Â Â Â Â sequence.append(n)Â Â print(sequence)modified_collatz(7) {codeBox}
A. [7, 36, 18, 9, 46, 23, 116, 58, 29, 146]
B. [7, 36, 18, 9, 28, 14, 7, 36, 18, 9]
C. [7, 20, 10, 5, 26, 13, 66, 33, 166, 83]
D. [7, 31, 15, 7, 36, 18, 9, 46, 23, 116]
Answer: [ A ] [7, 36, 18, 9, 46, 23, 116, 58, 29, 146]Â
Q9. Which technique is used in the PageRank algorithm to determine the rank of a web page?
A. Depth-First Search
B. Hyperlink Analysis
C. Random Walk Simulation
D. Data Scraping
Answer: [ C ] Random Walk Simulation
B. Hyperlink Analysis
C. Random Walk Simulation
D. Data Scraping
Answer: [ C ] Random Walk Simulation
Q10. In the PageRank algorithm, what happens when a page receives multiple inbound links from highly ranked pages?
A. Its rank decreases due to increased server load
B. Its rank improves
C. Its rank remains the same
D. It is considered less relevant
B. Its rank improves
C. Its rank remains the same
D. It is considered less relevant
Answer: [ B ]Â Â Its rank improves
Conclusion
Join us on Telegram 👉 CLICK HERE