Post

Ans---- 10
The code initializes a variable score to the value 10. Then, a new variable saved_score is assigned the current value of score, which is 10.
The score variable is then updated to 15, but this change does not affect the value already stored in saved_score.
The print function outputs the value of saved_score.
English

@PythonPr Answer: (a) 10
The code initializes the variable score to 10. The line saved_score = score assigns the current value of score (which is 10) to saved_score. Subsequent changes to the score variable (like adding 5 to it) do not affect the value already stored in
English

@PythonPr 10 — assignment copies the value, not a reference. Updating score later doesn’t affect savedscore.
English

@PythonPr Non-AI answer:
Score is a namespace that points to an object.
Saved_score points to the same object when compiled. Since Python is line-by-line execution, saved_score now just references the same object as score.
The score namespace is then reassigned to a new object.
English

@PythonPr 10. Integers don't get passed by reference because they are immutable. A list is mutable and doing b=a when a is mutable, then modifying a will modify b.
English

@PythonPr 10
when assigning the integer value to another variable, it is passed by value rather than reference, hence the addition operation doesn't affect the previous assigned value.
English

if at the same time, if the questions would have been:
score=[1]
saved_score=score
score+=[2]
print(saved_score)
here the answer would have been:
[1,2]
as due to the list being passed as a reference.
this is just a layer of abstraction in python, as in c++ we distinguish when to pass by value and reference.
English






























