Python Functions Questions and Answers

Take Exam

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

11. What is a docstring in Python functions?

  • A string that contains documentation
  • A special type of comment
  • A function that returns strings
  • A string variable inside function
Show Answer Report

12. How can you access a function"s docstring?

  • function.doc
  • function.__doc__
  • function.document
  • function.help
Show Answer Report

13. What is the scope of variables defined inside a function?

  • Global scope
  • Local scope
  • Module scope
  • Universal scope
Show Answer Report

14. Which keyword is used to modify a global variable inside a function?

  • global
  • nonlocal
  • extern
  • var
Show Answer Report

15. What is a recursive function?

  • A function that calls another function
  • A function that calls itself
  • A function with multiple returns
  • A function with no parameters
Show Answer Report

16. What is the purpose of the "nonlocal" keyword?

  • To declare global variables
  • To work with variables in nested functions
  • To create new local variables
  • To import non-local modules
Show Answer Report

17. What is function overloading in Python?

  • Defining multiple functions with same name but different parameters
  • Python doesn"t support traditional function overloading
  • Creating functions that are too long
  • Using functions in multiple modules
Show Answer Report

18. What is a generator function?

  • A function that generates random numbers
  • A function that uses yield instead of return
  • A function that creates other functions
  • A function that generates code
Show Answer Report

19. What is the difference between parameters and arguments?

  • Parameters are in definition, arguments are values passed
  • Arguments are in definition, parameters are values passed
  • They are the same thing
  • Parameters are for classes, arguments for functions
Show Answer Report

20. What are default parameters in Python functions?

  • Parameters that must be provided
  • Parameters with predefined values
  • Parameters that cannot be changed
  • Parameters that are always None
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test