Which of the following statements is true about dictionary keys?

Study for the PCEP Certified Entry-Level Python Programmer Exam. Access multiple choice questions and detailed explanations to enhance your learning. Prepare effectively for your certification!

Dictionary keys in Python must be unique and immutable, making the statement that keys must be case sensitive true. This is because Python treats keys with different cases as distinct. For instance, a dictionary with keys "Key" and "key" recognizes both as separate entries, thus allowing for a rich variety of key identification.

The other statements about keys are not accurate based on the properties of Python dictionaries. Mutable types, such as lists or dictionaries themselves, cannot be used as keys because their contents can change, which would compromise the dictionary's integrity. Keys must be immutable types like strings, numbers, or tuples. While keys can technically be reused in a dictionary, that means once you assign a new value to an existing key, it replaces the previous value rather than allowing multiple entries for the same key. So, while you can define new keys with the same name but in different dictionary contexts, you cannot have duplicate entries under the same dictionary instance. Therefore, the properties and behavior of dictionary keys in Python lead to the conclusion that they are case sensitive.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy