- Home
- Subjects
- Data Science
- Python
Python MCQs · Page 4
595 multiple choice questions with answers in Data Science.
What is the output of the following Python code snippet?
import heapq
print(heapq.nlargest(2, [1, 3, 2]))
print(heapq.nlargest(2, [1, 3, 2]))
What does int | None mean in a type hint (Python 3.10+)?
Which collections type provides O(1) appends and pops from both ends in Python?
What does np.arange(0, 10, 2) produce in Python?
What does PEP stand for in Python?
What is the output of the following Python code snippet?
from decimal import Decimal
print(Decimal('0.1') + Decimal('0.2'))
print(Decimal('0.1') + Decimal('0.2'))
Which sorting algorithm does Python's sorted() use?
What is pyproject.toml used for in Python?
What is the output of print({'a'} <= {'a': 1, 'b': 2}.keys()) in Python?
print({'a'}
What is the output of the following Python code snippet?
d = {'a': 3, 'b': 1, 'c': 2}
print(sorted(d, key=d.get))
print(sorted(d, key=d.get))
What is the output of the following Python code snippet?
class A:
@classmethod
def f(cls): return 'Cls'
print(A.f())
@classmethod
def f(cls): return 'Cls'
print(A.f())
What is the Singleton pattern in Python?
What is the output of print('hi'.encode()) in Python?
print('hi'.encode())
What is the output of print(sorted('listen') == sorted('silent')) in Python?
print(sorted('listen') == sorted('silent'))
What is the output of the following Python code snippet?
class A:
def __init__(self): self.x = 1
print(A().__dict__)
def __init__(self): self.x = 1
print(A().__dict__)
What is the end of life status of Python 2?
What is the default encoding for str.encode() in Python 3?
What is the output of print(sum(x for x in range(5))) in Python?
print(sum(x for x in range(5)))
Which module provides type hint helpers such as List, Optional and Union in Python?
What is the output of print(float('nan') == float('nan')) in Python?
print(float('nan') == float('nan'))
What is the output of print('{1} and {0}'.format(20, 10)) in Python?
print('{1} and {0}'.format(20, 10))