- Home
- All MCQs
All MCQs with Answers · Page 750
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?
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()
What is the difference between import x and from x import y in Python?
What is the output of print('Python'[-1]) in Python?
print('Python'[-1])
Which data structure in Python is best for fast membership checks?
Which tool is the standard package installer for Python?
What is the output of the following Python code snippet?
d = {'a': 1}
print(d.get('z', 0))
print(d.get('z', 0))
What is the output of print(any([])) in Python?
print(any([]))
What does a single leading underscore (_x) in a name signify in Python?
What is the output of the following Python code snippet?
from collections import Counter
print(Counter('aaabbc'))
print(Counter('aaabbc'))