Exercise for reference:

Create a dictionary that contains the keysa andb and their respective values1 and2.

Answer 1:

d = {"a": 1, "b": 2}

Explanation 1:

Using curly brackets is one way to create a dictionary.

Answer 2:

d = dict(a = 1, b = 2)

Explanation 2:

A dict function is another way to create a dictionary. dict is also used to convert other objects to a dictionary.