- Home
- All MCQs
All MCQs with Answers · Page 690
43,842 multiple choice questions from every subject, newest first. Switch on practice mode to hide the answers and test yourself.
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])
When does the else block of a try statement run in Python?
What is the time complexity of the in operator on a list in Python?
What is the output of the following Python code snippet?
x = 5
def f():
x = 10
f()
print(x)
def f():
x = 10
f()
print(x)
How do you define a custom exception in Python?
What does sys.getrefcount(obj) return in Python?
What is the output of the following Python code snippet?
a = [1, 2, 3]
a.append(4)
print(a)
a.append(4)
print(a)
What is the output of print(0.1 + 0.2 == 0.3) in Python?
print(0.1 + 0.2 == 0.3)
What is the output of the following Python code snippet?
def fact(n):
return 1 if n
What is the output of the following Python code snippet?
def greet(name='Guest'):
return f'Hello, {name}'
print(greet())
return f'Hello, {name}'
print(greet())
What does enumerate(items, start=1) do in Python?
What is the output of the following Python code snippet?
class Animal:
def speak(self): return 'Animal sound'
class Dog(Animal):
def speak(self): return 'Dog barks'
print(Dog().speak())
def speak(self): return 'Animal sound'
class Dog(Animal):
def speak(self): return 'Dog barks'
print(Dog().speak())
What is the output of the following Python code snippet?
i = 0
while i
Which special method allows an object to be called like a function in Python?
What is the output of print([5, 6, 7].index(7)) in Python?
print([5, 6, 7].index(7))
What does the nonlocal keyword do in Python?
Which module provides mathematical functions such as sqrt() and sin() in Python?
What is the output of the following Python code snippet?
def deco(f):
def w():
print('before')
f()
print('after')
return w
@deco
def hi():
print('hi')
hi()
def w():
print('before')
f()
print('after')
return w
@deco
def hi():
print('hi')
hi()