Computer Science
Assertion (A): In Python, a function can have default arguments.
Reasoning (R): Default arguments in Python functions are assigned values when the function is defined, and they can be used if no value is passed during the function call.
Python Functions
1 Like
Answer
Both A and R are true, and R is the correct explanation of A.
Explanation — In Python, a function can have default arguments. These default values are specified in the function header during the function definition. The default values for parameters are used only if no value is provided for that parameter in the function call.
Answered By
2 Likes
Related Questions
What will be the output of the following code ?
c = 10 def add(): global c c = c + 2 print(c, end = '#') add() c = 15 print(c, end = '%')- 12%15#
- 15#12%
- 12#15%
- 12%15#
State whether the following statement is True or False:
The
finallyblock in Python is executed only if no exception occurs in the try block.