DATA TYPES in PYTHON

HINA SAYYAD
3 min readJun 13, 2021

--

data types part-2

  • LIST
  • TUPLE
  • SET
  • DICTIONARY

We can access single elements from list by using positive indices or negative.

Lists are mutable, which means we can append elements and remove whenever needed. By using append() and remove() respectively.

A Tuple object is an ordered collection of one or more data items, not necessarily of the same type, put in parentheses

Like lists in tuple also we can access single elements with both positive and negative indices.

Tuple are immutable, which means we cannot append or remove any elements from a tuple.

In set we cannot access single elements because internally set does not store the data in the order we provide it. That is the reason it is called unordered collection of data. And as it is unordered data, certainly it doesn’t have indices

Set is mutable, which means we can add or remove the elements using add() and remove() respectively. But remember that the order in which it adds an element is not as we enter it.

No duplication, which means the data inside set are unique. Although duplicated entries will not give an error, the entries will not get stored and be seen on screen.

A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values. Each key will be mapped to a value.

Dictionaries are mutable — which means we can add and remove keys. A key can be removed by using pop( ).

QUIZ FOR YOU :

https://realpython.com/quizzes/pybasics-tuples-lists-dicts/

THANK YOU FOR READING :)

--

--

HINA SAYYAD

A vibrant mind with great personality.Always opine enigmatic thought about everything. Like to write about technology and lifestyle.