0% found this document useful (0 votes)
7 views

NPTEL Python For Data Science Week 2 Assignment Answer 2023

The document contains a series of questions and answers related to Python programming, specifically focusing on data types, indexing, and code outputs. It includes multiple-choice questions about NumPy arrays, tuples, dictionaries, and variable naming conventions. The assignment is part of the NPTEL Python for Data Science course for Week 2 in 2023.

Uploaded by

sathiya.set
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

NPTEL Python For Data Science Week 2 Assignment Answer 2023

The document contains a series of questions and answers related to Python programming, specifically focusing on data types, indexing, and code outputs. It includes multiple-choice questions about NumPy arrays, tuples, dictionaries, and variable naming conventions. The assignment is part of the NPTEL Python for Data Science course for Week 2 in 2023.

Uploaded by

sathiya.set
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

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

About Lesson
Q1. What is the output of the following code?

 36
 121212
 123
 Error: Invalid operation, unsupported operator ‘*’ used between ‘int’
and ‘str’
Answer:- b

Q2. What is the output of the following code?

 -1
 -2
 -1.28
 1.28
Answer:- b

Q3. Consider a following code snippet. What is a data type of y?

 int
 float
 str
 Code will throw an error
Answer:- c

Q4 Which of the following variable names are INVALID in Python?

 1_variable
 variable_1
 variable1
 variable#
Answer:- a d

Q5. While naming the variable, use of any special character other than
underscore(_) will throw which type of error?

 Syntax error
 Key error
 Value error
 Index error
Answer:- a

Q6. Let x = “Mayur”. Which of the following commands converts the ‘x’ to
float datatype?

 str(float,x)
 x.float()
 float(x)
 Cannot convert a string to float data type
Answer:- d

Q7. Which Python library is commonly used for data wrangling and
manipulation?

 Numpy
 Pandas
 scikit
 Math
Answer:- b

Q8. Predict the output of the following code.

 12.0
 12
 11.667
 11
Answer:- b

Q9. Given two variables, j = 6 and g = 3.3. If both normal division and
floor division operators were used to divide j by g, what would be the data
type of the value obtained from the operations?

 int, int
 float, float
 float, int
 int, float
Answer:- b

Q10. Let a = 5 (101 in binary) and b = 3 (011 in binary). What is the result
of the following operation?

 3
 7
 5
 1
Answer:- d

You might also like