In the previous class, we learned about strings in Python, and earlier we have covered all other basic data types in Python. Now we will step ahead to cover data structures which are a collection of other data types and have some unique properties.
Lists and tuples are ordered sequences and can contain any data type. Lists and tuples are like Arrays. Tuples like strings are immutables. Lists are mutable so they can be extended or reduced at will. Sets are mutable unordered sequences of unique elements whereas frozen sets are immutable sets.
Lists are enclosed in brackets:
Tuples are enclosed in parentheses. Tuples are faster and consume less memory.
Dictionaries are built with curly brackets:
l = [1, 2, "a"]
Tuples are enclosed in parentheses. Tuples are faster and consume less memory.
t = (1, 2, "a")
Dictionaries are built with curly brackets:
d = {"a":1, "b":2}
In the upcoming classes we'll be covering the following Data Structures :
1. Lists
2. Tuples
3. Dicts
4. Sets
5. Frozen sets

0 Comments