- Home
- Class - 12 CBSE Computer Science — Assertion Reason Type Questions
Assertion (A): You can add an element in a
Class - 12 CBSE Computer Science — Assertion Reason Type Questions
Assertion (A): You can add an element in a dictionary using key:value pair.
Reasoning (R): A new (key:value) pair is added only when the same key doesn't exist in the dictionary. If the key is already present, then the existing key gets updated and the new entry will be made in the dictionary.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Answer
Both A and R are true and R is the correct explanation of A.
Explanation
In Python, dictionaries are mutable, which means we can modify the key:value pairs, add new pairs, or remove existing pairs after the dictionary is created. When adding a new key:value pair to a dictionary, if the key already exists, its corresponding value will be updated. Otherwise, a new (key:value) pair will be added to the dictionary.