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
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#
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.