KnowledgeBoat Logo

Computer Science

What are the characteristics of Dictionary?

Python Dictionaries

1 Like

Answer

The characteristics of dictionary are as follows:

  1. Each key maps to a value — The association of a key and a value is called a key-value pair. However, there is no order defined for the pairs, thus, dictionaries are unordered.

  2. Each key is separated from its value by a colon (:). The items are separated by commas, and the entire dictionary is enclosed in curly braces {}.

  3. Keys are unique and immutable — Keys are unique within a dictionary while values are mutable and can be changed.

  4. Indexed by Keys — The elements in a dictionary are indexed by keys and not by their relative positions or indices.

  5. The value of a dictionary can be of any type, but the keys must be of an immutable data type such as strings, numbers or tuples.

  6. Dictionary is mutable — We can add new items, delete or change the value of existing items.

Answered By

1 Like


Related Questions