Post

@PythonPr Answer: A. [2, 4, 6, 8, 10]
In Python, when you assign one variable (like b) to another variable (like a) where the object is a mutable type such as a list, you are making a reference to the same object in memory, not a copy of the object itself.
Initially, both variables a and b
English

@PythonPr A) is correct
b[4] = 10 means we are modifying the element at index 4 in list b but a is also modified because b = a makes them point to the same list in memory.
English

@PythonPr Answer: A (yes, the list `a` gets modified!)
Solution: Let's see what's happening under the hood.
a = [2,4,6,8,9]
creates a list with those values, and attaches the name `a` to it.
b = a
this looks up the list referenced by `a`, and gives it an additional name, `b`.
So now
+
English

@PythonPr Strings are mutable so the answer is A. No cheating 🤪
English

@PythonPr The output of the above Python code is:
[2, 4, 6, 8, 10]
1. `b = a` creates a new reference to the same list object that `a` points to. Both `a` and `b` now point to the same memory location.
2. `b[4] = 10` changes the original list object that both `a` and `b` reference.
English

@PythonPr I thought B. After watching the comment section , I got to know the answer is B. Would you like to clarify the reason?
English





























