Sorry, you do not have permission to ask a question, You must login to ask a question.

# Python for Data Science Assignment Solutions Week 2 2022

Students, have you any doubt in Python for Data Science NPTEL assignment? So, below I have provided you solutions hints for this assignment. You can scroll down to clear your every doubt regarding this assignment.

## Python for Data Science NPTEL Assignment Solutions Week 2

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)

Answer: b. array.reshape(shape) & c. numpy.reshape(array, shape)

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_1[3] = 45

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]

Answer: b. job[len(job) – 1] & 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

Answer: b. By converting ls into a set

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

Answer: a. del states[‘Karnataka’] & c. states.pop(‘Karnataka’)

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

Answer: 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

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

Disclaimer: These answers are provided only for the purpose of helping students to take references. Sikshapath does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.

Also Available:

NPTEL Python for Data Science Week 1 Assignment Answers