codescracker
python

Difference between List, Tuple, Dictionary, and Set in Python



« Python Tutorial Python Examples »

This article is created to differentiate the four built-in data types of Python, that are used to store collection of data. The four built-in data types, that are differentiated here, are:

  1. list
  2. tuple
  3. dictionary
  4. set

The table given below, differentiates among above four data types of Python, in brief.

List Tuple Dictionary Set
ordered ordered ordered unordered
changeable (mutable) unchangeable (immutable) changeable mutable if created with set
immutable if created with frozenset
allows duplicates allows duplicates does not allows duplicates does not allows duplicates
List items enclosed within [ ] Tuple items enclosed within ( ) Dictionary items enclosed within { } Set items enclosed within { }
List can be created using list() Tuple can be created using tuple() Dictionary can be created using dict() Set can be created using set()

Python Online Test


« Python Tutorial Python Examples »



© Copyright 2021. All Rights Reserved.

CodesCracker