Python Functions Questions and Answers
Python Programming - Functions Questions with Answers help understand how to structure code using reusable blocks. These Python Functions Questions are key for TCS, Accenture, and SSC exams to assess coding logic and modular design
Python Functions
Showing 10 of
25 questions
2. Which of the following is used to return a value from a function?
- break
- return
- exit
- end
3. What is the output of: print(type(lambda x: x))
- <class "lambda">
- <class "function">
- <class "object">
- <class "type">
4. Which of these is a valid function definition?
- function my_func():
- def my_func():
- define my_func():
- func my_func():
5. What is a lambda function in Python?
- A function without a name
- A function that can only take one argument
- A function that returns lambda
- A special type of class
6. What is the default return value of a function that doesn"t have a return statement?
- 0
- None
- False
- An empty string
7. Which keyword is used to create an anonymous function?
- anonymous
- lambda
- def
- func
8. What is the purpose of *args in a function definition?
- To accept keyword arguments
- To accept variable-length positional arguments
- To accept only integer arguments
- To make arguments optional
9. What does the **kwargs parameter do in a function?
- Accepts only required arguments
- Accepts variable-length keyword arguments
- Accepts only string arguments
- Accepts dictionary as input
10. Which of these is a correct lambda function?
- lambda x: x + 1
- lambda (x): x + 1
- def lambda x: x + 1
- function lambda x: x + 1