- Home
- All MCQs
All MCQs with Answers · Page 749
45,334 multiple choice questions from every subject, newest first. Switch on practice mode to hide the answers and test yourself.
What is the output of the following Python code snippet?
try:
'python'.index('z')
except Exception as e:
print(type(e).__name__)
'python'.index('z')
except Exception as e:
print(type(e).__name__)
What is the main advantage of generators over lists in Python?
What does json.loads() do in Python?
What is the output of print(list(filter(lambda x: x % 2 == 0, [1, 2, 3, 4]))) in Python?
print(list(filter(lambda x: x % 2 == 0, [1, 2, 3, 4])))
What is the output of print('Python'.startswith('Py')) in Python?
print('Python'.startswith('Py'))
What is the output of print('Python'.replace('P', 'J')) in Python?
print('Python'.replace('P', 'J'))
What is the output of the following Python code snippet?
x = 5
print(1
What is the output of print(sorted(['banana', 'pie', 'apple'], key=len)) in Python?
print(sorted(['banana', 'pie', 'apple'], key=len))
Which module is used to work with JSON in Python?
What is the practical effect of the GIL on CPU-bound threads in CPython?
What exception is raised by int('abc') in Python?
What is the default indentation recommended by PEP 8 in Python?
What is the purpose of the if __name__ == '__main__': block in Python?
What does the assert statement do in Python?
What does setdefault(key, default) do in Python?
What does self refer to in an instance method in Python?
What does append() return in Python?
What is the output of print(1 in {'a': 1}) in Python?
print(1 in {'a': 1})
Which command creates a virtual environment in Python?
What is the output of the following Python code snippet?
class C:
@property
def pi(self): return 3.14
print(C().pi)
@property
def pi(self): return 3.14
print(C().pi)
What is the output of print(isinstance(int, object)) in Python?
print(isinstance(int, object))
What is the output of print('python'.find('z')) in Python?
print('python'.find('z'))
What is the output of print('Python'[1:4]) in Python?
print('Python'[1:4])