Computer Science
Assertion. A parameter having a default in function header becomes optional in function call.
Reason. A function call may or may not have values for default arguments.
Python Functions
1 Like
Answer
(a)
Both Assertion and Reason are true and Reason is the correct explanation of Assertion.
Explanation
When a parameter in a function header has a default value, it means that if no value is provided for that parameter during the function call, the default value will be used. This effectively makes the parameter optional in the function call. When calling a function with default arguments, we have the option to either provide values for those arguments or omit them, in which case the default values will be used.
Answered By
1 Like
Related Questions
Assertion. A function is a subprogram.
Reason. A function exists within a program and works within it when called.
Assertion. Non-default arguments cannot follow default arguments in a function call.
Reason. A function call can have different types of arguments.
Assertion. A variable declared inside a function cannot be used outside it.
Reason. A variable created inside a function has a function scope.
Assertion. A variable not declared inside a function can still be used inside the function if it is declared at a higher scope level.
Reason. Python resolves a name using LEGB rule where it checks in Local (L), Enclosing (E), Global (G) and Built-in scopes (B), in the given order.