Test Index

CBSE Class 12 Computer Science 2026 Paper Set 4 Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 7 of 37
Marks: +1, -0
Which of the following statements is true about dictionaries in Python ?
Solution:  
Concept:
A dictionary is a mapping of unique keys to values.
Explanation:
(A) False: a dictionary is a mapping type, not a sequence (its elements are not accessed by position 0, 1, 2, ...).
(B) True: keys are unique. Assigning to an existing key replaces its old value, e.g. {1:'a', 1:'b'} gives {1: 'b'}.
(C) False: values may repeat, e.g. {1:'a', 2:'a'} is valid.
(D) False: {5:5} is valid; a key and its value may be equal.
Answer:
Option B (A dictionary cannot have two elements with same key.)
© examsnet.com
Advertisements
Go to Question: