def add(x, y): x += y return x a = 5 b = 3 c = add(a, b) print(a) ————————————— A- 8 B- 5 C- 3 D- Error #Python #برمجة

Python_quiz's tweet image. def add(x, y):
    x += y
    return x

a = 5
b = 3
c = add(a, b)
print(a)
—————————————
A- 8
B- 5
C- 3
D- Error

#Python #برمجة

Hi .. py beginner. Pydroid3 gives answer 5. Is that correct, pls advise or reference. I thought it wld add x(5) to y(3) giving 8 and put 8 back in x returning 8 as answer. Wheres the flaw in my thinking please. If answer is 5 then why hasn't x been incremented. thanks. G


United States الاتجاهات
Loading...

Something went wrong.


Something went wrong.