- Home
- MCQs by exam
- Python Interview Functions
- Data Science
Python Interview Functions MCQs – Data Science
25 multiple choice questions typical of the Python Interview Functions exam, with answers and explanations. Switch on practice mode to test yourself first.
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 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])))
What is the output of the following Python code snippet?
sq = lambda x: x * x
print(sq(5))
print(sq(5))
Which built-in returns a function's documentation string in Python?
What is the output of the following Python code snippet?
def f(a, b):
return a * b
print(f(b=5, a=3))
return a * b
print(f(b=5, a=3))
What exception is raised when the recursion limit is exceeded in Python?
What does a docstring do in Python?
What is the output of print(callable(len)) in Python?
print(callable(len))
What does a bare * in def f(a, *, b) mean in Python?
What is the output of print(sorted([3, 1, 2], key=lambda x: x)) in Python?
print(sorted([3, 1, 2], key=lambda x: x))
What is the output of the following Python code snippet?
def f(**kwargs):
return kwargs
print(f(a=1, b=2))
return kwargs
print(f(a=1, b=2))
What does LEGB stand for in Python scope resolution?
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 the following Python code snippet?
x = 5
def f():
x = 10
f()
print(x)
def f():
x = 10
f()
print(x)
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 the nonlocal keyword do in Python?
What is the output of the following Python code snippet?
def mul(n):
def inner(x):
return x * n
return inner
print(mul(2)(4))
def inner(x):
return x * n
return inner
print(mul(2)(4))
What is the default recursion limit in CPython?
What is the output of the following Python code snippet?
def f(a, b): return a + b
print(f(a=1, 2))
print(f(a=1, 2))
What is the recommended way to avoid the mutable default argument pitfall in Python?
What does the / in a function signature def f(a, /, b) mean in Python?
What are type hints in Python?
What is the output of the following Python code snippet?
def f(x: int) -> int:
return x
print(f.__annotations__)
return x
print(f.__annotations__)