What will be the output of the following Python function when called with my_func(1, 2)?
def my_func(x, y=1):
if x < y:
x = 2 * x
if x == y:
x += 1
y -= 2
return (x, y)
Real Exam
Explanation:
The function my_func is called with x = 1 and y = 2. Since x < y is True, x is doubled to 2. Then, x == y is True (both are 2), so x is incremented to 3 and y is decremented to 0. Therefore, the function returns (3, 0).