- Home
- MCQs by exam
- Python Interview Standard Library
Python Interview Standard Library MCQs
44 multiple choice questions typical of the Python Interview Standard Library exam, with answers and explanations. Switch on practice mode to test yourself first.
How can you get an environment variable without raising KeyError if missing in Python?
What is the default logging level of the root logger in Python?
What does sys.exit() do in Python?
In regular expressions, what does the dot . match by default in Python?
Which method converts a datetime to a formatted string in Python?
Which pathlib method reads a whole text file in Python?
Which function creates a directory including missing parents in Python?
Which module copies and removes whole directory trees in Python?
What is the output of the following Python code snippet?
from datetime import date, timedelta
print(date(2024, 1, 1) + timedelta(days=10))
print(date(2024, 1, 1) + timedelta(days=10))
What does json.dumps(obj, indent=2) do in Python?
What does time.time() return in Python?
What is the output of the following Python code snippet?
from datetime import date
print((date(2024, 1, 8) - date(2024, 1, 1)).days)
print((date(2024, 1, 8) - date(2024, 1, 1)).days)
What is the difference between bytes and bytearray in Python?
Which module runs external commands and captures their output in Python?
Which function is recommended for measuring elapsed time precisely in Python?
What is the output of the following Python code snippet?
from pathlib import Path
print(Path('file.txt').suffix[1:])
print(Path('file.txt').suffix[1:])
What is the naming convention for unittest test methods in Python?
Which module encodes data to Base64 in Python?
What does the doctest module do in Python?
Which module performs binary search on a sorted list in Python?
What does re.match() check in Python?
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 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'))
What is the output of print('hi'.encode()) in Python?
print('hi'.encode())