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.
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.
Related Questions
Write a Python program using two functions area and perimeter to compute the area and perimeter of a rectangle. The program should take length and breadth of the rectangle as input from the user.
State whether the following statement is True or False:
The
finallyblock in Python is executed only if no exception occurs in the try block.