NPTEL Joy Of Computing Using Python Week 12 Assignment 2025

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

Join us on Telegram 👉 CLICK HERE  

NPTEL Joy Of Computing Using Python Week 12 Assignment 2025

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 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), (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}

Answer:  [ A ] 

The above code creates a graph with a fixed number of edges and nodes . You have to select the output that best describes the code. The code may create a different shape but the number of edges and nodes is always fixed. 

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.

Which of the following graphs is generated by the given Python code using the networkx module?


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)

Q3. Observe the following graph generated using the networkx module. How many edges does this graph contain?


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?


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

Q5. Observe the following graph generated using the networkx module. What type of graph is this?



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

Barbell Graph:  Two complete graphs connected by a path  

Barbell Graph


Q6. What will be the output of the following code?

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}

A. (4, 4)
B. (4, 8)
C. (4, 2)
D. (8, 4)

Answer: [ A ] (4, 4)

mport 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()))

Q7. What is the output of this code?

def collatz_steps(n):
    steps=0
    while n!=1:
        n = n//2 if n%2 == 0 else 3 * n + 1
        steps += 1
    return steps
print(collatz_steps(7)) {codeBox}

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 steps print(collatz_steps(7))

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] 

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)

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

Which technique is used in the PageRank algorithm to determine the rank of a web page?


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

Answer: [ B ]   Its rank improves

In the PageRank algorithm, what happens when a page receives multiple inbound links from highly ranked pages?

Conclusion

Join us on Telegram 👉 CLICK HERE

One Comment Please !

Post a Comment (0)
Previous Post Next Post