Python for Data Science NPTEL Week 2 Assignment Answers 2026

Are you looking for the Python for Data Science NPTEL Week 2 Assignment Answers 2026? You’ve come to the right place! This guide offers detailed solutions to the Week 2 assignment questions, helping you solidify your understanding of Python programming and its applications in data science.


Python for Data Science Nptel Week 2 Assignment Answers
Python for Data Science Nptel Week 2 Assignment Answers 2026

Python for Data Science NPTEL Week 1 Assignment Answers (Jan-Apr 2026)

Que.1
Which of the following object does not support indexing?

a) tuple
b) list
c) dictionary
d) set

View Answer


Que.2
How can you concatenate the strings “data” and “science” with a hyphen (-) between them?

a) "data".join("science")
b) "-".join(["data", "science"])
c) "data" + "-" + "science"
d) None of the above

View Answer


Que.3
What will be the output of the following code snippet?

a)

[[ 5 12]
 [21 32]]

b)

[[19 22]
 [43 50]]

c)

[[3 8]
 [35 56]]

d)

[[ 5 21]
 [12 32]]

View Answer


Que.4
What will be the output of the following code snippet?

a) [1 10 3 4 5 6 7 8 9 10]
b) [10 1 2 3 4 5 6 7 8 9]
c) [0 10 2 3 4 5 6 7 8 9]
d) [10 2 3 4 5 6 7 8 9]

View Answer


Que.5
What is the output of the following code?

a) [2, 3, 4, 5]
b) [0, 1, 2, 3]
c) [1, 2, 3, 4]
d) Will throw an error: Set objects are not iterable

View Answer


Que.6
What will be the output of the following code snippet?

a) {27.5}
b) {1, 'four ', 3.0, 3, 5, 'two ', 10, 27.5}
c) {1, 'four ', 3.0, 5, 'two ', 10, 27.5}
d) {1, 'four ', 3.0, 5, 'two ', 3}

View Answer


Que.7
Let t1 = (1, 2, "tuple", 4) and t2 = (5, 6, 7). Which of the following will not give any error after execution?

a) t1.append(5)
b) x = t2[t1[1]]
c) t3 = t1 + t2
d) t3 = (t1, t2)
e) t3 = (list(t1), list(t2))

View Answer


Que.8
Let d = {1 : "Python", 2 : [1, 2, 3]}. Which among the following will not give an error after execution?

a) d[2].append(4)
b) x = d[0]
c) d["one"] = 1
d) d.update({'one' : 2})

View Answer


Que.9
Which of the following data type is immutable?

a) list
b) set
c) tuple
d) dictionary

View Answer


Que.10
student = {'name': 'Jane', 'age': 25, 'courses': ['Math', 'Statistics']}
Which among the following will return
{'name': 'Jane', 'age': 26, 'courses': ['Math', 'Statistics'], 'phone': '123-456'}

a) student.update({'age' : 26})
b) student.update({'age' : 26, 'phone': '123-456'})
c) student['phone'] = '123-456'
d) student.update({'age' : 26})
e) None of the above

View Answer


Que.11
What is the output of the following code?

a) ['M', 'A', 'H', 'E', 'S', 'H']
b) ['m', 'a', 'h', 'e', 's', 'h']
c) ['M', 'a', 'h', 'e', 's', 'h']
d) ['m', 'A', 'H', 'E', 'S', 'H']

View Answer


Que.12
What will be the output of the following code snippet?

a)

[[1 2 3 4 5]
 [3 4 5 6 7]
 [5 6 7 8 9]]

b)

[[1 2 3 4]
 [3 4 5 6]
 [5 6 7 8]]

c)

[[2 3 4]
 [4 5 6]
 [6 7 8]]

d) None of the above

View Answer


(July-Dec 2025)


Question 1. Which of the following object does not support indexing?
a) tuple
b) list
c) dictionary
d) set

View Answers


Question 2. How can you concatenate the strings “data” and “science” with a hyphen(-) between them?
a) “data”.join(“science”)
b) “-”.join([“data”, “science”])
c) “data” + “-” + “science”
d) None of the above.

View Answers


Question 3. What will be the output of the following code snippet?
a) [[ 5 12], [21 32]]
b) [[19 22], [43 50]]
c) [[3 8], [35 56]]
d) [[ 5 21], [12 32]]

View Answers


Question 4. What will be the output of the following code snippet?
a) [ 1 10 3 4 5 6 7 8 9 10]
b) [ 10 1 2 3 4 5 6 7 8 9]
c) [ 0 10 2 3 4 5 6 7 8 9]
d) [ 10 2 3 4 5 6 7 8 9 ]

View Answers


Question 5. What is the output of the following code?
a) [2, 3, 4, 5]
b) [0, 1, 2, 3]
c) [1, 2, 3, 4]
d) Will throw an error: Set objects are not iterable.

View Answers


Question 6. What will be the output of the following code snippet?
a) {27.5}
b) {1, ‘four ‘, 3.0, 3, 5, ‘two ‘, 10, 27.5}
c) {1, ‘four ‘, 3.0, 5, ‘two ‘, 10, 27.5}
d) {1, ‘four ‘, 3.0, 5, ‘two ‘, 3}

View Answers


Question 7. Let t1 = (1, 2, “tuple”, 4) and t2 = (5, 6, 7). Which of the following will not give any error after the execution?
a) t1.append(5)
b) x = t2[t1[1]]
c) t3 = t1 + t2
d) t3 = (t1, t2)
e) t3 = (list(t1), list(t2))

View Answers


Question 8. Let d = {1 : “Pyhton”, 2 : [1, 2, 3]}. Which among the following will not give the error after the execution?
a) d[2].append(4)
b) x = d[0]
c) d[“one”] = 1
d) d.update({‘one’ : 2})

View Answers


Question 9. Which of the following data type is immutable?
a) list
b) set
c) tuple
d) dictionary

View Answers


Question 10. student = {‘name’: ‘Jane’, ‘age’: 25, ‘courses’: [‘Math’, ‘Statistics’]}
Which among the following will return
{‘name’: ‘Jane’, ‘age’: 26, ‘courses’: [‘Math’, ‘Statistics’], ‘phone’: ‘123-456’}?

a) student.update({‘age’ : 26})
b) student.update({‘age’ : 26, ‘phone’: ‘123-456’})
c) student[‘phone’] = ‘123-456’
d) student.update({‘age’ : 26})
e) None of the above

View Answers


Question 11. What is the output of the following code?
a) [‘M’, ‘A’, ‘H’, ‘E’, ‘S’, ‘H’]
b) [‘m’, ‘a’, ‘h’, ‘e’, ‘s’, ‘h’]
c) [‘M’, ‘a’, ‘h’, ‘e’, ‘s’, ‘h’]
d) [‘m’, ‘A’, ‘H’, ‘E’, ‘S’, ‘H’]

View Answers


Question 12. What will be the output of the following code snippet?
a) [[1 2 3 4 5], [3 4 5 6 7], [5 6 7 8 9]]
b) [[1 2 3 4], [3 4 5 6], [5 6 7 8]]
c) [[2 3 4], [4 5 6], [6 7 8]]
d) None of the above

View Answers


(Jan-Apr 2025)

Course Link: Click Here


1) Which of the following objects does not support indexing?
Options:
[a] tuple
[b] list
[c] dictionary
[d] set

View Answers


2) How can you concatenate the strings “data” and “science” with a hyphen (-) between them?
Options:
[a] "data".join("science")
[b] ".join(["data", "science"])
[c] "data" + "science"
[d] None of the above

View Answers


3) What will be the output of the following code snippet?

import numpy as np
c = np.dot(a, b)
print(c)

Options:
[a] [5, 12]
[b] [21, 32]
[c] [[19, 22], [43, 50]]
[d] [35, 56]

View Answers


4) What will be the output of the following code snippet?

import numpy as np
a = np.arange(10)
b = 10
print(a)

Options:
[a] [1, 10, 9]
[b] [10, 8, 9]
[c] [0, 10, 9]
[d] [10, 2, 3, 4, 5, 6, 7, 8, 9]

View Answers


5) What is the output of the following code?

for i in range(len(s)):
    print(i)

Options:
[a] Will throw an error: Set objects are not iterable.
[b] Will print the indices of the set.
[c] Will print the elements of the set.
[d] Will run indefinitely.

View Answers


6) What will be the output of the following code snippet?

A = {1, 2, 3}
B = {3, 4, 5}
print(A | B)

Options:
[a] {27.5}
[b] {1, 2, 3, 4, 5}
[c] {1, 2, 3}
[d] {4, 5}

View Answers


7) Given the tuples tl = (1, 2, "tuple", 4) and t2 = (5, 6, 7), which of the following will not give any error after execution?
Options:
[a] tl.append(5)
[b] list(t2)
[c] tl + t2
[d] (tl, t2)

View Answers


8) Given the dictionary d = {1: "Python", 2: [1, 2]}, which of the following will not give an error after execution?
Options:
[a] d[2].append(4)
[b] d[1] = 1
[c] d["one"] = 1
[d] None of the above

View Answers


9) Which of the following data types is immutable?
Options:
[a] list
[b] set
[c] tuple
[d] dictionary

View Answers


10) Given the dictionary student = {"name": "Jane", "age": 26, "courses": ["Math", "Science"]}, which of the following will return the phone number?
Options:
[a] student['phone']
[b] student['phone'] = '123-456'
[c] student['phone']
[d] None of the above

View Answers


11) What is the output of the following code?

name = "Mahesh"
for i in name:
    t.append(i.capitalize())
print(t)

Options:
[a] ["M", "A", "H", "E", "S", "H"]
[b] ["Mahesh"]
[c] ["Mahesh".capitalize()]
[d] None of the above

View Answers


12) What will be the output of the following code snippet?

import numpy as np
a = np.array([range(i, i+4) for i in range(3)])
print(a)

Options:
[a] [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]]
[b] [[3, 4, 5, 6], [5, 6, 7, 8]]
[c] [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]]
[d] None of the above

View Answers


(JULY-DEC 2024)


Q1. Which of the following object does not support indexing?
tuple
list
dictionary
set

Answer: set


Q2. Given a NumPy array, arr = np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]), what is the output of the command, print(arr[0][1])?

[[1 2 3]
[4 5 6]
[7 8 9]]
[1 2 3]
[4 5 6]
[7 8 9]

Answer: [4 5 6]


For answers or latest updates join our telegram channel: Click here to join

These are Python for Data Science Nptel Week 2 Assignment Answers


Q3. What is the output of the following code?

[2, 3, 4, 5]
[0 1 2 3]
[1, 2, 3, 4]
Will throw an error: Set objects are not iterable.

Answer:[1, 2, 3, 4]


Q4. What is the output of the following code?

import numpy as np
arr = np.array (np.arange(0, 15))
print(arr.reshape (3,5))

Answer: c)


For answers or latest updates join our telegram channel: Click here to join

These are Python for Data Science Nptel Week 2 Assignment Answers


Q5. Which of the following code gives output My friend’s house is in Chennai?

Answer: a),d)


Q6. Let t1 = (1, 2, “tuple”, 4) and t2 = (5, 6, 7). Which of the following will not give any error after the execution?

a) t1.append(5)

b) x=t2[t1[1]]

c) t3=t1+t2

d) t3=(t1,t2)

e) t3=(list(t1),list(t2))

Answer: b),c),d),e)


For answers or latest updates join our telegram channel: Click here to join

These are Python for Data Science Nptel Week 2 Assignment Answers


Q7. Let d= {1 : “Pyhton”, 2 : [1, 2, 3]}. Which among the following will not give the error after the execution?

a) d[2].append(4)

b) x=d[0]

c) d[“one”]=1

d) d.update(‘one′:2)

Answer: a),c),d)


Q8. Which of the following data type is immutable?
list
set
tuple
dictionary

Answer: tuple


For answers or latest updates join our telegram channel: Click here to join

These are Python for Data Science Nptel Week 2 Assignment Answers


Q9. student = {‘name’: ‘Jane’, ‘age’: 25, ‘courses’: [‘Math’, ‘Statistics’]}
Which among the following will return

{‘name’: ‘Jane’, ‘age’: 26, ‘courses’: [‘Math’, ‘Statistics’], ‘phone’: ‘123-456’}
a) student.update({‘age’ : 26})
b) student.update({‘age’ : 26, ‘phone’: ‘123-456’})
c) student[‘phone’] = ‘123-456’
d) student.update({‘age’ : 26})
e) None of the above

Answer: b),c)


Q10.What is the output of the following code?

[‘M’, ‘A’, ‘H’, ‘E’, ‘S’, ‘H’]
[‘m’, ‘a’, ‘h’, ‘e’, ‘s’, ‘h’]
[‘M’, ‘a’, ‘h’, ‘e’, ‘s’, ‘h’]
[‘m’, ‘A’, ‘H’, ‘E’, ‘S’, ‘H’]

Answer: [‘M’, ‘A’, ‘H’, ‘E’, ‘S’, ‘H’]


For answers or latest updates join our telegram channel: Click here to join

These are Python for Data Science Nptel Week 2 Assignment Answers

Python for Data Science NPTEL All weeks: Click Here

More Nptel Courses: https://progiez.com/nptel-assignment-answers


(JAN-APR 2024)

Course name: Python For Data Science

Course Link: Click Here

For answers or latest updates join our telegram channel: Click here to join

These are NPTEL Python for Data Science Assignment 2 Answers


Q1. Which of the following object does not support indexing?
tuple
list
dictionary
set

Answer: set


Q2. Given a NumPy array, arr = np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]), what is the output of the command, print(arr[0][1])?
a. [[1 2 3]
[4 5 6]
[7 8 9]
b. [1 2 3]
c. [4 5 6]
d. [7 8 9]

Answer: c. [4 5 6]


Q3. What is the output of the following code?
[2, 3, 4, 5]
[0 1 2 3]
[1, 2, 3, 4]
Will throw an error: Set objects are not iterable.

Answer: [1, 2, 3, 4]


For answers or latest updates join our telegram channel: Click here to join

These are NPTEL Python for Data Science Assignment 2 Answers


Q4. What is the output of the following code?
a)
b)
c)
d)

Answer: c) [[0 1 2 3 4 [ 5 6 7 8 9] [10 11 12 13 14]]


Q5. Which of the following code gives output My friend’s house is in Chennai?
a)
b)
c)
d)

Answer: a), d)
a) place = ‘Chennai’
print (“My friend’s house is in {}”. format (place) )
d) print (“My friend’s house is in {}”. format (“Chennai”) )


Q6. Let t1=(1,2,“tuple”,4) and t2=(5,6,7). Which of the following will not give any error after the execution?
t1.append(5)
x=t2[t1[1]]
t3=t1+t2
t3=(t1,t2)
t3=(list(t1), list(t2))

Answer: b, c, d, e


For answers or latest updates join our telegram channel: Click here to join

These are NPTEL Python for Data Science Assignment 2 Answers


Q7. Let d={1:“Pyhton”,2:[1,2,3]}. Which among the following will not give the error after the execution?
d[2].append(4)
x=d[0]
d[“one”]=1
d.update({‘one’ : 2})

Answer: a, c, d


Q8. Which of the following data type is immutable?
list
set
tuple
dictionary

Answer: tuple


Q9. student = {‘name’: ‘Jane’, ‘age’: 25, ‘courses’: [‘Math’, ‘Statistics’]}
Which among the following will return
{‘name’: ‘Jane’, ‘age’: 26, ‘courses’: [‘Math’, ‘Statistics’], ‘phone’: ‘123-456’}?

a. student.update({‘age’ : 26})
b. student.update({‘age’ : 26, ‘phone’: ‘123-456’})
c. student[‘phone’] = ‘123-456’
student.update({‘age’ : 26})
d. None of the above

Answer: a, b, c


Q10. What is the output of the following code?
[‘M’, ‘A’, ‘H’, ‘E’, ‘S’, ‘H’]
[‘m’, ‘a’, ‘h’, ‘e’, ‘s’, ‘h’]
[‘M’, ‘a’, ‘h’, ‘e’, ‘s’, ‘h’]
[‘m’, ‘A’, ‘H’, ‘E’, ‘S’, ‘H’]

Answer: [‘M’, ‘A’, ‘H’, ‘E’, ‘S’, ‘H’]


For answers or latest updates join our telegram channel: Click here to join

These are NPTEL Python for Data Science Assignment 2 Answers

More Weeks of Python for Data Science: Click here

More Nptel Courses: Click here


(JAN-APR 2023)

Course Name: Python for Data Science

Course Link: Click Here

These are NPTEL Python for Data Science Assignment 2 Answers


Q1. What will be the output of the following:

image 69

a. [[2 6 10]
[4 8 12]]
b. [[2 4 6]
[8 10 12]]
c. [[2 4]
[6 8]
[10 12]]
d. [[2 8]
[4 10]
[6 12]]

Answer: b. [[2 4 6]
[8 10 12]]


Q2. Let t1 = (1, 2, “tuple”, 4) and t2 = (5, 6, 7). Which of the following will not give any error after the execution?
a. t1.append(5)
b. x = t2[t1[1]]
c. t3 = t1 + t2
d. t3 = (t1, t2)
e. t3 = (list(t1), list(t2))

Answer: a, b, c, d, e


These are NPTEL Python for Data Science Assignment 2 Answers


Q3. Let d1 = {1 : “Pyhton”, 2 : [1, 2, 3]}. Which among the following will not give the error after the execution?
a. d1[2].append(4)
b. x = d1[0]
c. d1[“one”] = 1
d. d1.update({‘one’ : 2})

Answer: a, c, d


Q4. S1 = {1, 2, 3}
S2 = {5, 6, 3}
S1.add(4)
S2.add(“4”)
What will be the output of S1 − S2?

a. {1, 2, 3}
b. {1, 2, 3, 4}
c. {1, 2, “4”}
d. {1, 2, 4}

Answer: d. {1, 2, 4}


These are NPTEL Python for Data Science Assignment 2 Answers


Q5. S1 = “Hello” and S2 = “World”. Which of the following will not return “Hello world”?
a. S1 + “ ” + S2
b. S1[0 :] + “ ” + S2[0 :]
c. “{} {}”.format(S1, S2)
d. S1[: −1] + “ ” + S2[: −1]

Answer: d. S1[: −1] + “ ” + S2[: −1]


Q6. Given a NumPy array, arr = np.array([[1, 9, 10], [3, 7, 6], [12, 8, 0]]), find the correct command from the following options to get an output array as [16 24 16]?
a. arr[1: 2]
b. np.sum(arr, axis = 0)
c. np.sum(arr, axis = 1)
d. np.sum([[1, 9, 10], [3, 7, 6], [12, 8, 0]])

Answer: b. np.sum(arr, axis = 0)


These are NPTEL Python for Data Science Assignment 2 Answers


Q7. mat = np.matrix(“5, 9, 10; 2, 5, 4; 1, 9, 8; 2, 6, 8”)
mat1 = np.matrix(“1, 2, 3, 4”)
mat2 = np.insert(mat, 1, mat1, axis= 1)
print(mat2)
What will be the output of the above command?

a. [[5 2 1 2]
[1 2 3 4]
[9 5 9 6]]
[10 4 8 8]]
b. [[1 2 3 4]
[5 2 1 2]
[9 5 9 6]]
[10 4 8 8]]
c. [[5 1 9 10]
[2 2 5 4]
[1 3 9 8]]
[2 4 6 8]]
d. It will give an error.

Answer: d. It will give an error.


Q8. student = {‘name’: ‘Jane’, ‘age’: 25, ‘courses’: [‘Math’, ‘Statistics’]}
Which among the following will return
{‘name’: ‘Jane’, ‘age’: 26, ‘courses’: [‘Math’, ‘Statistics’], ‘phone’: ‘123-456’}

a. student.update({‘age’ : 26})
b. student.update({‘age’ : 26, ‘phone’: ‘123-456’})
c. student[‘phone’] = ‘123-456’
d. student.update({‘age’ : 26})
e. None of the above

Answer: b, c


These are NPTEL Python for Data Science Assignment 2 Answers


Q9. c = np.arange(start = 1, stop = 20, step = 3). What is c[5]?
a. 13
b. 16
c. 15
d. 12

Answer: b. 16


Q10. Which of the following data type is immutable?
a. list
b. set
c. tuple
d. dictionary

Answer: c. tuple


These are NPTEL Python for Data Science Assignment 2 Answers

More Weeks of Python for Data Science NPTEL: Click here

More NPTEL courses: https://progiez.com/nptel


(JULY-DEC 2022)

Q1. Which of the following function(s) can be used to resize a NumPy array in Python from the given options.
a. array.shape(reshape)
b. array.reshape(shape)
c. numpy.reshape(array, shape)
d. numpy.reshape(shape, array)

Answers: b, c


These are NPTEL Python for Data Science Assignment 2 Answers


2. Create the tuples given below:
tuple_1 = (1,5,6,7,8)
tuple_2 = (8,9,4)

Identify which of the following options does not work on the given tuples

a. sum(tuple_1)
b. len(tuple_2)
c. tuple_2 + tuple_1
d. tuple_1[3] = 45

Answers: d. tuple_1[3] = 45


3. Create a sequence of numbers from 15 to 25 and increment by 4. What is the index of the element 19?
a. 3
b. 2
c. 0
d. 1

Answers: d. 1


These are NPTEL Python for Data Science Assignment 2 Answers


4. Consider a variable job = “chemist”. Which of the following expression(s) will retrieve the last character from the string?

a. job[7]
b. job[len(job) – 1]
c. job[5:6]
d. job[- 1]

Answers: b, c


5. Given a list, ls = [1, 2, 3, 3, 2, 3, 1, 4, 5, 6, 5, 6, 3, 2, 1, 1, 1, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 10, 10, 1, 2, 3, 9, 10], which of the following would be the most efficient method in determining the unique elements present in ls?
a. By converting ls into a NumPy array, and applying relevant methods
b. By converting ls into a set
c. By iterating through ls, and doing appropriate manipulations
d. None of the above

Answers: b. By converting ls into a set


These are NPTEL Python for Data Science Assignment 2 Answers


6. Which of the following data structure(s) can be used as a key while creating a dictionary?
a. list
b. str
c. set
d. None

Answers: b. str


7. Given a dictionary, states = {‘Tamil Nadu’: ‘TN’, ‘Karnataka’: ‘KA’, ‘Kerala’: ‘KL’, ‘Maharashtra’: ‘MH’}, which of the following command(s) is used to remove the key-value pair ‘Karnataka’: ‘KA’ from it?
a. del states[‘Karnataka’]
b. states.popitem(‘Karnataka’)
c. states.pop(‘Karnataka’)
d. del states[‘Karnataka’:’KA’]

Answers: c. states.pop(‘Karnataka’)


8. Which of the following is valid to declare a string literal Shin’ichi to a variable?
a. “Shin’ichi”
b. ‘Shin”ichi’‘
c. Shin’ichi’
d. None of the above

Answers: a. “Shin’ichi”


These are NPTEL Python for Data Science Assignment 2 Answers


9. Which of the following commands can be used to create a NumPy array?
a. np.array()
b. np.zeros()
c. np.empty()
d. All of the above

Answers: d. All of the above


10. Given a NumPy array, arr = np.array([[5,9,10], [7,2,6], [12,8,0]]), find the correct command from the following options to get an output array as [24 15 20]?

a. np.sum(arr)
b. np.sum(arr, axis = 0)
c. np.sum(arr, axis = 1)
d. None of the above

Answers: c. np.sum(arr, axis = 1)


These are NPTEL Python for Data Science Assignment 2 Answers