Computer Science
Assertion (A): Function can take input values as parameters, execute them and return output (if required) to the calling function with a return statement.
Reasoning (R): A function in Python can return multiple values.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Answer
Both A and R are true and R is the correct explanation of A.
Explanation
Functions in Python can take input values as parameters, perform operations on them, and return output if needed using the return statement. A function in Python can return multiple values using a single return statement by separating the values with commas.
Related Questions
What is the output of the following snippet?
def fun(n): if (n > 100): return n - 5 return fun (fun (n+11) ) print(fun(45))
- 50
- 100
- 74
- Infinite loop
What happens if the base condition isn't defined in recursive programs?
- Program gets into an infinite loop
- Program runs once
- Program runs n number of times, where n is the argument given to the function
- An exception is thrown
Assertion (A): If the arguments in a function call statement match the number and order of arguments as defined in the function definition, such arguments are called positional arguments.
Reasoning (R): During a function call, the argument list first contains default argument(s) followed by positional argument(s).
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): Local Variables are accessible only within a function or block in which they are declared.
Reasoning (R): Global variables are accessible in the whole program.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.