Python | MCQs and Answers | Data Science | Assignment 1 | Quiz 1

preview_player
Показать описание
1. What will be the output of the following:

print(c)

Ans: [[ 2 4 6]
[ 8 10 12]]

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

x = t2[t1[1]]
t3 = t1 + t2
t3 = (t1, t2)
t3 = (list(t1), list(t2))

Ans:
x = t2[t1[1]]
t3 = t1 + t2
t3 = (t1, t2)
t3 = (list(t1), list(t2))

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

Ans:
d1[2].append(4)
d1["one"] = 1

4. S1 = {1, 2, 3}
S2 = {5, 6, 3}

What will be the output of S1 − S2?
{1, 2, 3}
{1, 2, 3, 4}
{1, 2, “4”}
{1, 2, 4}
Ans: {1, 2, 4}

5. S1 = “Hello” and S2 = “World”. Which of the following will not return “Hello world”?

S1 + “ ” + S2
S1[0 :] + “ ” + S2[0 :]
“{} {}”.format(S1, S2)
S1[: −1] + “ ” + S2[: −1]

Ans: S1[: −1] + “ ” + S2[: −1]

arr[1: 2]

print(mat2)

What will be the output of the above command?

Ans:
[[ 5 1 9 10]
[ 2 2 5 4]
[ 1 3 9 8]
[ 2 4 6 8]]

8. 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[‘phone’] = ‘123-456’
None of the above
Ans:
student['phone'] = '123-456'

Ans: 16
10. Which of the following data type is immutable?
list
set
tuple
dictionary

Ans: tuple
Рекомендации по теме