Computer Science
Assertion (A): The return statement in Python allows a function to return more than one value at a time.
Reasoning (R): Python functions can return multiple values as a tuple, which is unpacked only if necessary.
Python Functions
3 Likes
Answer
Both A and R are true, and R is the correct explanation of A.
Explanation — In Python, a function can return more than one value at a time by returning multiple values separated by commas. These values are packed into a tuple. If needed, the tuple can be unpacked into separate variables.
Answered By
1 Like
Related Questions
State whether the following statement is True or False:
The
finallyblock in Python is executed only if no exception occurs in the try block.Assertion (A): Positional arguments in Python functions must be passed in the exact order in which they are defined in the function signature.
Reasoning (R): This is because Python functions automatically assign default values to positional arguments.
- Both A and R are true, and R is the correct explanation of A.
- Both A and R are true, and R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.