Post

@PythonPr Code:
x = 5
y = x
x = 10
print(y)
Step by step:
x is 5
y gets the value of x → y = 5
x changes to 10
y does NOT change
So the output is:
5
Correct answer: B) 5
English

@PythonPr 5. Python passes values to a variable by object reference. Since y is int, it is immutable, therefore, y is a new object different from x and allocated different memory. Therefore, changes in x does not impact y.
English

@PythonPr It's 5 as the value of y will not change by the X down there
English

@PythonPr B, because of positional assignment of x to 5 before x to 10
English





















