Dictionaries in Python
A dictionary is a special type of data storage in the form of key-value pairs.
To create dictionaries, you need to use curly braces. Let's make an empty dictionary:
dct = {}
Now let's set string keys and numeric values:
dct = {
'a': 1,
'b': 2,
'c': 3
}
Given a dictionary:
dct = {}
Add three new elements to it.
Let's say you have numbers 2, 4 and 6. Create a dictionary with these numbers as keys. The values should be the strings 'ab', 'cd', 'ef'.
Create a dictionary with the keys surname, name, age. In the dictionary values, write down your last name, first name, and age.
Create a dictionary with months. Let the keys be the ordinal numbers of the months, and the values be their names.