NPTEL Python for Data Science Assignment 2 Answers 2023:- All the Answers provided below to help the students as a reference, You must submit your assignment at your own knowledge.
NPTEL Python For Data Science Week 2 Assignment Answer 2023
1. Which of the following object does not support indexing?
- tuple
- list
- dictionary
- set
Answer :- Click Here
2. 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 :- Click Here
3. 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 :- Click Here
4. What is the output of the following code?
Answer :- Click Here
5. Which of the following code gives output My friend’s house is in Chennai?
Answer :- Click Here
6. 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 :- Click Here
7. 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’ : 22})
Answer :- Click Here
8. Which of the following data type is immutable?
- list
- set
- tuple
- dictionary
Answer :- Click Here
9. student = {‘name’: ‘Jane’, ‘age’: 25, ‘courses’: [‘Math’, ‘Statistics’]}
Which among the following will return
{‘name’: ‘Jane’, ‘age’: 26, ‘courses’: [‘Math’, ‘Statistics’], ‘phone’: ‘123-456’}?
- student.update({‘age’ : 26})
- student.update({‘age’ : 26, ‘phone’: ‘123-456’})
- student[‘phone’] = ‘123-456’
- student.update({‘age’ : 26})
- None of the above
Answer :- Click Here
10. 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 :- Click Here
NPTEL Python for Data Science Assignment 2 Answers 2022 [July-Dec]
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, c
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
Answer:- d
Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
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
Answer:- d
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]
Answer:- b, d
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
Answer:- b
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
Answer:- b
👇For Week 03 Assignment Answers👇
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’]
Answer:- c
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
Answer:- a
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
Answer:- For Answer Click Here
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
Answer:- c
For More NPTEL Answers:- CLICK HERE
Join Our Telegram:- CLICK HERE
About Python For Data Science
The course aims at equipping participants to be able to use python programming for solving data science problems.
CRITERIA TO GET A CERTIFICATE
Average assignment score = 25% of average of best 3 assignments out of the total 4 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100
Final score = Average assignment score + Exam score
YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.
NPTEL Python for Data Science Assignment 2 Answers 2022 [Jan – June]
Q1. Consider a variable job = “chemist”. Which of the following expressions will retrieve the last character from the variable value?
(A) job[7]
(B) job[len(job) – 1]
(C) job[5:6]
(D) job[- 1]
(D) All of the above statements are true
Answer:- (B) & (D)
Q2. Which of the following expressions should be used to assign the variable get_num to get the final print statement output as value 75 from the below tuple?
(A) nst_tup[1][2]
(B) nst_tup[1:2][1]
(C) nst_tup[1][1]
(D) nst_tup[1:2](1)
(D) None of the above
Answer:-(C) nst_tup[1][1]
Q3. What would be the output for the following set of statements?
(A) [13, 23, 18, 64, 51, “True”]
(B) [13, 23, 18, 64, True]
(C) [13, 23, 18, 64, 51, True]
(D) Index Error
Answer:- (B) [13, 23, 18, 64, True]
Q4. What result does the final statement print?
(A) Output is: 12, (25, 32, 39), 44
(B) Output is: 12 and (25, 32, 39) and 44
(C) Output is: 12 and 25 and 39 ValueError: Too many values to unpack
(D) Output is: 12 and [25, 32, 39] and 44
Answer:- (D) Output is: 12 and [25, 32, 39] and 44
Q5. When the following set of instructions are executed, how many times does the vowel “e” appear in the result?
(A) 1
(B) “e” is not printed
(C) 2
(D) 4
(E) None of the above
Answer:- For Answer Click Here
Q6. Which of the following options, when executed, will result in a tuple?
(A) t = (2,2)
(B) y =[‘h’,’4′,’3′]
(C) r = (‘v’,)
(D) s = (‘w’)
(D) All except b
Answer:- (A) & (C)
Q7. Which statement/ statements will result in an empty datastructure?
(A) dict1 = {}
(B) tup1 = ()
(C) st1 = set()
(D)
(E) All of the above
Answer:- (E) All of the above
Q8. Consider a dictionary city created with the following keys and values.
Through which all possible way / ways can we access the value 5 from the dictionary city?
(A) city[‘Bengaluru’]
(B) city.get[‘Bengaluru’]
(C) city.values()[1]
(D) list(city.values())[1]
(E) None of the above
Answer:- (A) & (D)
Q9. Count the number of elements in the below list.
(A) 2
(B) 1
(C) 3
(D) 0
(E) None of the above
Answer:- (B) 1
Q10. A datastructure is defined as celebrate = set(‘Nativity Day’). What are the possible outputs if celebrate is printed?
1. {‘v’, ‘N’, ‘t’, ‘i’, ‘y’, ‘a’, ‘D’}
2. {‘v’, ‘N’, ‘t’, ‘I’, ‘y’, ‘a’, ‘D’, ‘ ‘}
3. {‘v’, ‘N’, ‘t’, ‘i’, ‘y’, ‘a’, ‘D’, ‘ ‘}
4. {‘v’, ‘t’, ‘i’, ‘y’, ‘a’, ‘D’, ‘ ‘, ‘N’}
(A) 1
(B) 1 and 3
(C) 1,2,3
(D) 3 and 4
(E) All are correct
Answer:- For Answer Click Here
Disclaimer:- We do not claim 100% surety of solutions, these solutions are based on our sole expertise, and by using posting these answers we are simply looking to help students as a reference, so we urge do your assignment on your own.
For More NPTEL Answers:- CLICK HERE
Join Our Telegram:- CLICK HERE
NPTEL Python for Data Science Assignment 2 Answers 2022:- All the Answers provided here to help the students as a reference, You must submit your assignment at your own knowledge.