
Answer-first summary for fast verification
Answer: (3, 0)
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)`.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
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)
def my_func(x, y=1):
if x < y:
x = 2 * x
if x == y:
x += 1
y -= 2
return (x, y)
A
(2, 1)
B
(1, 2)
C
(3, 0)
D
(1, 1)
E
(2, 2)
No comments yet.