NPTEL The Joy of Computing using Python Week 9 Assignment Answers 2024
1. What is stylometry?
a. The study of language evolution
b. The study of linguistic style in written texts
c. The study of speech patterns in public speaking
d. The study of language acquisition in children
✅ Answer :- b
Explanation: Stylometry is the quantitative study of writing style, especially for author identification.
2. What are the different attributes that can be checked in addition to average word length to identify the style of a particular author? [MSQ]
a. Punctuation usage
b. Word Frequency
c. Usage of Stylistic Devices like Metaphors, Similes, etc
d. Average Sentence Length
✅ Answer :- a, b, c, d
Explanation: All these features contribute to determining an author’s unique writing style.
3. The following code tries to perform natural language analysis for a small piece of text without using the nltk library. Select all correct statements: [MSQ]

a. y
represents the sum of lengths of words in text
b. z
represents the average word length of text
c. x
is a list where each index corresponds to the length of a word in text
d. The output of the code is: 36 7.2
✅ Answer :- a, b, c, d
Explanation: Each statement accurately describes the variables and output involved in the code.
4. The following code tries to calculate average sentence length of a given block of text in the form of a file, assuming that the sentences always end with full stops and that there are no ellipsis(…) in the block of text. But the code might contain errors. Identify the line number corresponding to the error. In the absence of an error input your answer as -1(NAT)

✅ Answer :- 5
Explanation: Line 5 likely contains a logic or syntax error during sentence splitting or length calculation.
5. What does the following code do?
- A graph having 5 nodes which are integers from 1 to 5 and 10 edges in total is created and the edges and nodes of the graph are printed
- A graph having 6 nodes which are integers from 1 to 6 and 10 edges in total is created and the edges and nodes of the graph are printed
- A graph having 5 nodes which are integers from 1 to 5 and 9 edges in total is created and the edges and nodes of the graph are printed
- A graph having 6 nodes which are integers from 1 to 6 and 9 edges in total is created and the edges and nodes of the graph are printed
✅ Answer :- a
Explanation: Based on the description, 5 nodes and 10 edges are defined and printed.
6. What is the most appropriate graph property to identify influential individuals in a social network?
a. Node degree
b. Graph density
c. Graph diameter
d. Edge weight
✅ Answer :- a
Explanation: Node degree indicates how many connections a person has—key to identifying influence.
7. In Milgram’s “small world experiment”, what was the average number of intermediaries?
a. 1 degree
b. 3 degrees
c. 6 degrees
d. 10 degrees
✅ Answer :- c
Explanation: The “six degrees of separation” theory came from this experiment.
8. Given a file with edges of the graph, and each line representing an edge in the format “node 1 node 2”, the following code attempts to plot a graph based on the data given. But the code might contain errors. Identify the line number corresponding to the error. In the absence of an error type your answer as -1.

✅ Answer :- -1
Explanation: The code is correctly implemented; hence, no error is present.
9. Using the ideas from Area Calculation discussed in the lecture, we are trying to estimate the area of a quarter circle embedded in a square. Identify the line number corresponding to the error(if any) in the absence of error type your answer as -1


✅ Answer :- -1
Explanation: The code correctly uses the Monte Carlo method; no line contains an error.
10. Select correct statements regarding area calculation by random sampling method. [MSQ]
a. Can handle area calculation even for irregular shapes
b. Always computationally efficient for all scenarios
c. More random points reduce random variations
d. Accuracy improves with more points due to the law of large numbers
✅ Answer :- a, c, d
Explanation: While it works well for irregular shapes and improves with more samples, it’s not always the most efficient.
11. Select the correct statement regarding the PIL library.
a. PIL stands for Python Image Library
b. Pillow is the active successor of PIL
c. Image.open()
is used to open images in PIL
d. All of the above
✅ Answer :- d
Explanation: All statements are accurate about the PIL (and Pillow) library for image processing.