Tuple, Dictionary and Sets

MOHIT MEHLAWAT
2 min readJul 18, 2021

Tuple

In Python, the tuple is used to store the sequence of immutable Python objects. They are similar to lists but with one exception that the value of the items stored in the tuple cannot be changed.

Tuple Methods

Tuples have built-in methods, but not as many as lists do. Some of the most commonly used methods of tuple are shown below.

Immutability

Tuples are immutable, that is, once a tuple is created no item can be replaced and no new item can be appended to the tuple.

Dictionary

In Python, dictionary is used to store data in a key-value pair format. Each key-value pair maps the key to its associated value. It is a mutable data structure.

Accessing Values in Dictionary

A value in a dictionary is retrieved by specifying its corresponding key in square brackets [].

Methods in Dictionary

Some of the most commonly used methods in dictionary are shown below.

Sets

A Set in Python is the collection of the unordered items. The elements in the set are unique, therefore, duplicate elements is not allowed. A set itself may be modified, but the elements contained in the set must be of an immutable type.

--

--