Sets are unordered collections that can contain only unique values
my_list = [apple, banana, 4, 20]
print(my_list)
Lists can also be defined using the list constructor as shown below.
another_list = list((a, b, c))
print(another_list)
Tuples are immutable, this means that we cannot change the values of a tuple, trying to do so would result in an error. Below is how tuples are created.
my_tuple = (1, 2, 3, 4)
print(my_tuple)
print(type(my_tuple))
Using the inbuilt type function gives us the type of an object.
Sets are unordered collections that can contain only unique values. Sets are created using curly braces as shown below.
my_set = 1, 1, 2, 2, 2, three
print(my_set)
print(type(my_set))
In the example above, notice that all duplicate entries are removed when the set is created and there is no concept of ordering.
A dictionary is a collection of key value pairs that are unordered and can be changed. Dictionaries are created using curly braces with each key pointing to its corresponding value.
my_dict = 1: one, 2: two, 3: three
print(my_dict)
print(type(my_dict))
There are other data types in Python but these are by far the most commonly used ones. To understand more about these data structures and which operations that can be performed on them, read through the official Python documentation.