Python Programming - Functions
Exercise : Functions - General Questions
- Functions - General Questions
1.
What is the purpose of the
def
keyword?
Answer: Option
Explanation:
The
def
keyword is used to define a function in Python.
2.
What will be the result of the following code snippet?
def add_numbers(a, b):
return a + b
result = add_numbers(3, 7)
print(result)
Answer: Option
Explanation:
The function
add_numbers
adds the values of a
and b
(3 + 7), resulting in 10.
3.
How do you pass a default value to a function parameter?
Answer: Option
Explanation:
Default values for function parameters are assigned using the
parameter=default_value
syntax.
4.
What is the purpose of the
return
statement in a function?
Answer: Option
Explanation:
The
return
statement is used to exit a function and return a value to the caller.
5.
What does the term "function signature" refer to?
Answer: Option
Explanation:
The function signature includes the name of the function and the list of parameters along with their types.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers