Day 10 - Collections
In Python we have few data types for collections,
- List
- Tuple
- Dictionary
- Set
This is important to understand and remember before we dive into Loop
Sometimes these kind of collections are also known as array. So if you hear the term array then it means a kind of collection.
List
# List (ordered and changeable) [allow duplocate]
theList = ["cycle", "scooter", "car"]
print(theList)
print(type(theList)) #<class 'list'>
Tuple
# Tuple (ordered and unchangeable) [allow duplicate]
theTuple = ("cycle", "scooter", "car")
print(theTuple)
print(type(theTuple)) #<class 'tuple'>
Set
# Set (unordered and unindexed) [NO duplicate]
theSet = {"cycle", "scooter", "car"}
print(theSet)
print(type(theSet)) #<class 'set'>
Dictionary
# Dictionary (unordered, changeable and indexed) [NO duplicate]
theDictionary = {
"1": "Wriju",
"2": "Wrishika",
"3": "Writam"
}
print(theDictionary)
print(type(theDictionary)) #<class 'dict'>
Watch the video
Day 10 - Exercise
- Try all the options above with differnt combinations of words. Practice again and again.