List: is ordered in the order its placed in. It's values can be changed.
grades = [77, 80, 90, 95, 100]
Tuple: is a list that can't be changed.
tuple_grades = (77, 80, 90, 95, 100)
Sets: is a unique & unordered list. 2nd 100 will get removed.
set_grades = {77, 80, 90, 100, 100}
print(set_grades)
# output
# {80, 90, 100, 77}
Dictionaries: is a key value pair.
my_dict = {'name': 'Jose', 'age': 90}
my_dict = {'name': 'Jose', 'age': 90}
print(my_dict['name'])
# Output
# Jose
universities = [ # List
{ # Dictionary
'name': 'Oxford',
'location': 'UK'
},
{ # Dictionary
'name': 'MIT',
'location': 'USA'
}
]
lottery_player = { # Dictionary
'name': 'Rolf',
'numbers': (12, 45, 66, 52, 22) # Tuple
}
some_dict = { # Dictionary
'name': 'Rolf',
'age': 90,
'grades': [13, 50, 30, 12, 88]
}
Sum operations
lottery_player = { # Dictionary
'name': 'Rolf',
'numbers': (12, 45, 66, 52, 22) # Tuple
}
sum(lottery_player['numbers'])
# Output
# 197 # Sum of the
another_dict_in_dict = {
'key': {
'name': 'Jose'
}
}