- Home
- All MCQs
All MCQs with Answers · Page 746
45,334 multiple choice questions from every subject, newest first. Switch on practice mode to hide the answers and test yourself.
Which special method makes an object usable in a for loop in Python?
How do you remove duplicates from a list while ignoring order in Python?
What is a closure in Python?
What is the output of the following Python code snippet?
a = [1, 2, 3]
a.insert(1, 9)
print(a)
a.insert(1, 9)
print(a)
What is the output of print(0 or 0) in Python?
print(0 or 0)
What is the output of the following Python code snippet?
import copy
a = [1, [2, 3]]
b = copy.copy(a)
b[1][1] = 99
print(a, b)
a = [1, [2, 3]]
b = copy.copy(a)
b[1][1] = 99
print(a, b)
What is the output of the following Python code snippet?
def f(x, lst=[]):
lst.append(x)
return lst
f(1)
print(f(2))
lst.append(x)
return lst
f(1)
print(f(2))
What does functools.partial do in Python?
How does Python define a block of code such as a loop body or function body?
What is the output of print(list(map(lambda x: x * x, [1, 2, 3]))) in Python?
print(list(map(lambda x: x * x, [1, 2, 3])))
Which special method makes len(obj) work in Python?
What is a frozenset in Python?
What is the output of the following Python code snippet?
sq = lambda x: x * x
print(sq(5))
print(sq(5))
What is the output of print(True + True) in Python?
print(True + True)
Which module in the standard library is used for regular expressions in Python?
Which module serialises Python objects to a binary format?
What does the os module provide in Python?
Which built-in returns a function's documentation string in Python?
What is the output of the following Python code snippet?
try:
1 / 0
except ZeroDivisionError:
print('Cannot divide by zero')
1 / 0
except ZeroDivisionError:
print('Cannot divide by zero')
What is the maximum value of an int in Python 3?
What is the output of print('42'.zfill(5)) in Python?
print('42'.zfill(5))
Which mode opens a file for appending text in Python?
What is the output of the following Python code snippet?
x = 3
print('big' if x > 5 else 'small')
print('big' if x > 5 else 'small')
What is the output of print(f'{3.14159:.2f}') in Python?
print(f'{3.14159:.2f}')