Data Science MCQs · Page 17
1,613 multiple choice questions with answers across 28 topics.
Which command prints the Zen of Python?
What does the break statement do in Python?
Which keyword is used to define a function in Python?
What does the / in a function signature def f(a, /, b) mean in Python?
What is the output of the following Python code snippet?
x = 2
match x:
case 1:
print('One')
case 2:
print('Two')
case _:
print('Three')
match x:
case 1:
print('One')
case 2:
print('Two')
case _:
print('Three')
Which library is most commonly used for tabular data analysis in Python?
What is the difference between shallow copy and deep copy in Python?
What is the output of the following Python code snippet?
for i in range(2):
print(i, end=' ')
else:
print('done')
print(i, end=' ')
else:
print('done')
What error is raised when accessing a missing dict key with d[key] in Python?
What are type hints in Python?
What does MRO stand for in Python?
What is the output of the following Python code snippet?
def f(x: int) -> int:
return x
print(f.__annotations__)
return x
print(f.__annotations__)
What is a virtual environment in Python?
What is the output of the following Python code snippet?
import re
print(re.findall(r'\d+', 'ab12cd345'))
print(re.findall(r'\d+', 'ab12cd345'))
What is the output of the following Python code snippet?
m = [[0] * 2] * 2
m[0][0] = 1
print(m)
m[0][0] = 1
print(m)
What does functools.lru_cache do in Python?
Which collections class provides default values for missing keys in Python?
What is the output of the following Python code snippet?
d = {'a': 1, 'b': 2}
d.update({'b': 3, 'c': 4})
print(d)
d.update({'b': 3, 'c': 4})
print(d)
What is the output of print(all([1, 2, 3])) in Python?
print(all([1, 2, 3]))
What is the output of print(list(range(5, 0, -1))) in Python?
print(list(range(5, 0, -1)))
What is the output of print([x for x in range(5) if x % 2 == 0]) in Python?
print([x for x in range(5) if x % 2 == 0])
What is the output of print([3, 1, 2].sort()) in Python?
print([3, 1, 2].sort())
What is the output of the following Python code snippet?
d = {'a': 1, 'b': 2}
print({k: v for k, v in d.items() if v
What is the output of print({1, 2} ^ {2, 3}) in Python?
print({1, 2} ^ {2, 3})