# NPTEL Python for Data Science Assignment 2 Answers 2022

NPTEL Python for Data Science Assignment 2 Answers:- Hello students in this article we are going to share NPTEL Python for Data Science assignment week 2 answers. All the Answers provided below to help the students as a reference, You must submit your assignment at your own knowledge.

Below you can find NPTEL Python for Data Science Assignment 2 Answers

### NPTEL Python for Data Science Assignment 2 Answers 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)

Q2. 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_2 + tuple_1

Q3. 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

Q4. 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]

Q5. 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

Q6. 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

Q7. 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’]

Q8. 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

Q9. 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

Q10. 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