Advertisements
Advertisements
प्रश्न
Which of the following statements is true about dictionaries in Python?
पर्याय
A dictionary is an example of sequence data type.
A dictionary cannot have two elements with same key.
A dictionary cannot have two elements with same value.
The key and value of an element cannot be the same.
MCQ
Advertisements
उत्तर
A dictionary cannot have two elements with same key.
Explanation:
- Unique Keys: In Python, dictionary keys must be unique. If you try to assign a value to an existing key, it simply overwrites the old value.
- Mapping Type: Unlike lists or tuples, a dictionary is a mapping datatype, not a sequence.
- Values: While keys must be unique, a dictionary can have multiple elements with the same value, and a key and its value can also be the same.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
