Loading

Quipoin Menu

Learn • Practice • Grow

python-for-ai / Functions
mcq
Direction: Choose the correct option

Q1.

Which keyword defines a function in Python?
A. lambda
B. def
C. func
D. function
Direction: Choose the correct option

Q2.

What is the output of `def add(a,b): return a+b; print(add(2,3))`?
A. 2,3
B. None
C. 5
D. Error
Direction: Choose the correct option

Q3.

What is a default argument?
A. A variable-length argument
B. An argument that has a default value if not provided
C. A keyword argument
D. An argument that must be provided
Direction: Choose the correct option

Q4.

What does `def func(*args):` do?
A. Accepts keyword arguments
B. Returns a tuple
C. Accepts variable number of positional arguments
D. Defines a default argument
Direction: Choose the correct option

Q5.

What does `def func(**kwargs):` do?
A. Accepts a dictionary
B. Accepts positional arguments
C. Accepts variable number of keyword arguments
D. Returns a dictionary
Direction: Choose the correct option

Q6.

What is the scope of a variable defined inside a function?
A. Enclosing
B. Global
C. Built-in
D. Local
Direction: Choose the correct option

Q7.

What is a lambda function?
A. A named function
B. An anonymous function
C. A built-in function
D. A recursive function
Direction: Choose the correct option

Q8.

What is the output of `(lambda x: x*2)(3)`?
A. 9
B. 3
C. Error
D. 6
Direction: Choose the correct option

Q9.

How do you call a function with keyword arguments?
A. func([1,2])
B. func(a=1, b=2)
C. func({a:1,b:2})
D. func(1,2)
Direction: Choose the correct option

Q10.

What is the purpose of the `return` statement?
A. To print a value
B. To define a function
C. To loop
D. To exit a function and optionally return a value