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
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
12. How can you access a function"s docstring?
- function.doc
- function.__doc__
- function.document
- function.help
13. What is the scope of variables defined inside a function?
- Global scope
- Local scope
- Module scope
- Universal scope
14. Which keyword is used to modify a global variable inside a function?
- global
- nonlocal
- extern
- var
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
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
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
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
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
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