Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b)Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d)A is false but R is True
Assertion(A): List is an immutable data type
Reasoning(R): When an attempt is made to update the value of an immutable variable, the old variable is destroyed and a new variable is created by the same name in memory.
Answer
Answer by student
(d) A is false but R is true
Detailed answer by teachoo
-lock-
- The assertion (A) is false because list is a mutable data type, not an immutable one. This means that the elements of a list can be changed or modified without creating a new list object. For example:
As you can see, the list object numbers were not destroyed or replaced by a new one. It was simply updated with a new value at index 0.
- The reasoning (R) is true because it describes the behavior of an immutable data type, such as a string or a tuple. When an attempt is made to update the value of an immutable variable, the old variable is destroyed and a new variable is created by the same name in memory. For example:
As you can see, the string object name cannot be modified in place. It is an immutable data type that does not allow item assignment. If we want to change the value of name , we have to create a new string object and assign it to the same variable name. For example:
As you can see, the original string object name was destroyed and replaced by a new one with a different value.
- Therefore, the correct choice is (d) A is false but R is true. The assertion is false and the reasoning is true . The assertion is about lists, which are mutable data types, while the reasoning is about immutable data types.
So, the correct answer is (d) A is false but R is true.
-endlock-