Professional Documents
Culture Documents
There are four collection data types in the Python programming language:
1. List
2. Tuple
3. Set
4. Dictionary
List:
List is a collection which is ordered, mutable and changeable. It allows duplicate members. Each
element or value that is inside of a list is called an “item”.
Example:
print(list)
Output:
Tuple:
Tuple is a collection which is ordered and unchangeable. It also allows duplicate members.
In Python tuples are written with round brackets. Tuples are used to group together related data,
such as a person's name, their age, and their gender.
Example:
Output:
Set:
Set is a collection which is unordered and unindexed. It does not allow duplicate members.
In Python sets are written with curly brackets.
Example:
print(thisset)
Output:
Dictionary:
Dictionary is a collection which is unordered, changeable and indexed. It also not allow duplicate
members. In Python, dictionaries are written with curly brackets, and they have keys and values.
Example:
thisdict = {
“brand” : “Apple”,
“model” : “hot9”,
“year” : 2020
print(thisdict)
Output:
{‘brand’ : ‘Apple’, ‘model’: ‘hot9’, ‘year’: 2020}