Q1. What is a function in Python?
✅ Correct Answer: (B) A block of reusable code
📘 Explanation: A function is a reusable block of code that performs a specific task.
📘 Explanation: A function is a reusable block of code that performs a specific task.
Q2. Which keyword is used to define a function in Python?
✅ Correct Answer: (B) def
📘 Explanation: The def keyword is used to define a function.
📘 Explanation: The def keyword is used to define a function.
Q3. What is the correct syntax to define a function?
✅ Correct Answer: (C) def myFunc():
📘 Explanation: Functions are defined using def function_name():
📘 Explanation: Functions are defined using def function_name():
Q4. Which statement is used to return a value from a function?
✅ Correct Answer: (C) return
📘 Explanation: return sends a value back to the caller.
📘 Explanation: return sends a value back to the caller.
Q5. What is the output of the following code?
def add(): return 5 + 3 print(add())
✅ Correct Answer: (B) 8
📘 Explanation: The function returns 8, which is printed.
📘 Explanation: The function returns 8, which is printed.
Q6. Which type of function does not return a value?
✅ Correct Answer: (C) Void function
📘 Explanation: Void functions do not return any value explicitly.
📘 Explanation: Void functions do not return any value explicitly.
Q7. Which of the following is a built-in Python function?
✅ Correct Answer: (A) input()
📘 Explanation: input() is a built-in Python function.
📘 Explanation: input() is a built-in Python function.
Q8. How many values can a Python function return?
✅ Correct Answer: (C) Any number
📘 Explanation: Python functions can return multiple values as tuples.
📘 Explanation: Python functions can return multiple values as tuples.
Q9. What is the output of the following code?
def show(x): print(x) print(show(10))
✅ Correct Answer: (B) None
📘 Explanation: The function prints 10 but returns None.
📘 Explanation: The function prints 10 but returns None.
Q10. What are function parameters?
✅ Correct Answer: (B) Values passed to function definition
📘 Explanation: Parameters are variables defined in the function header.
📘 Explanation: Parameters are variables defined in the function header.
Q11. What are arguments in Python functions?
✅ Correct Answer: (A) Values passed during function call
📘 Explanation: Arguments are the actual values passed to parameters.
📘 Explanation: Arguments are the actual values passed to parameters.
Q12. Which function allows anonymous functions?
✅ Correct Answer: (B) lambda
📘 Explanation: lambda creates small anonymous functions.
📘 Explanation: lambda creates small anonymous functions.
Q13. What is the correct syntax for a lambda function?
✅ Correct Answer: (A) lambda x: x+1
📘 Explanation: Lambda functions are written as lambda arguments: expression
📘 Explanation: Lambda functions are written as lambda arguments: expression
Q14. What is recursion?
✅ Correct Answer: (C) Function calling itself
📘 Explanation: Recursion occurs when a function calls itself.
📘 Explanation: Recursion occurs when a function calls itself.
Q15. Which keyword stops the execution of a function?
✅ Correct Answer: (B) return
📘 Explanation: return ends function execution and sends back a value.
📘 Explanation: return ends function execution and sends back a value.
Q16. What is the default return value of a function with no return statement?
✅ Correct Answer: (C) None
📘 Explanation: Python functions return None by default.
📘 Explanation: Python functions return None by default.
Q17. Which of the following is used to pass variable-length arguments?
✅ Correct Answer: (A) *args
📘 Explanation: *args allows passing multiple positional arguments.
📘 Explanation: *args allows passing multiple positional arguments.
Q18. Which of the following is used for keyword arguments?
✅ Correct Answer: (B) **kwargs
📘 Explanation: **kwargs allows passing keyword arguments.
📘 Explanation: **kwargs allows passing keyword arguments.
Q19. Which function returns the length of an object?
✅ Correct Answer: (C) len()
📘 Explanation: len() returns the number of items in an object.
📘 Explanation: len() returns the number of items in an object.
Q20. Which function is used to get user input?
✅ Correct Answer: (C) input()
📘 Explanation: input() reads input from the user.
📘 Explanation: input() reads input from the user.