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
1. What keyword is used to define a function in Python?
  • function
  • def
  • define
  • func
Show Answer Report
2. Which of the following is used to return a value from a function?
  • break
  • return
  • exit
  • end
Show Answer Report
3. What is the output of: print(type(lambda x: x))
  • <class "lambda">
  • <class "function">
  • <class "object">
  • <class "type">
Show Answer Report
4. Which of these is a valid function definition?
  • function my_func():
  • def my_func():
  • define my_func():
  • func my_func():
Show Answer Report
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
Show Answer Report
6. What is the default return value of a function that doesn"t have a return statement?
  • 0
  • None
  • False
  • An empty string
Show Answer Report
7. Which keyword is used to create an anonymous function?
  • anonymous
  • lambda
  • def
  • func
Show Answer Report
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
Show Answer Report
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
Show Answer Report
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
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test