Computer Science
Assertion. Dictionaries are mutable, hence its keys can be easily changed.
Reason. Mutability means a value can be changed in place without having to create new storage for the changed value.
Python Dictionaries
1 Like
Answer
(d)
Assertion is false but Reason is true.
Explanation
Dictionaries are indexed by keys and each key must be immutable and unique. However, the dictionary itself is mutable, meaning that we can add, remove, or modify key-value pairs within the dictionary without changing the identity of the dictionary object itself. Mutability refers to the ability to change a value in place without creating a new storage location for the changed value.
Answered By
1 Like
Related Questions
Assertion. Modifying a string creates another string internally but modifying a list does not create a new list.
Reason. Strings store characters while lists can store any type of data.
Assertion. Modifying a string creates another string internally but modifying a list does not create a new list.
Reason. Strings are immutable types while lists are mutable types of python.
Assertion. Dictionaries are mutable but their keys are immutable.
Reason. The values of a dictionary can change but keys of dictionary cannot be changed because through them data is hashed.
Assertion. In Insertion Sort, a part of the array is always sorted.
Reason. In Insertion sort, each successive element is picked and inserted at an appropriate position in the sorted part of the array.