An Alternative Way to Create a Dictionary in Python

An alternative way to create dictionaries is to use the dict function. You need to pass a key-value pair to its parameters. If you do not specify anything in the parameters, the created dictionary will be empty:

pythondct = dict()
print(dct) # {}

Now let's create a dictionary with two elements. To do this, we pass a string key to the first parameter of the function, but without quotes. After it, we put the operator = and write the value. Separated by a comma, we specify the second pair:

pythondct = dict(a='1', b='2')
print(dct) # {'a': '1', 'b': '2'}

However, you cannot pass numbers as keys to the dict functions. In this case, an error will be returned:

pythondct = dict(1='a', 2='b') # will display an error
Задание 1

The following code is given:

pythondct = dict(a=1, b=2, c=3)
print(dct)

Tell me what will be output to the console.

Задание 2

The following code is given:

pythondict('1'='a', '2'='b', '3'='c')
print(dct)

Tell me what will be output to the console.

Задание 3

The following code is given:

pythondict(a='12', b='34', c='56')
print(dct)

Tell me what will be output to the console.

Задание 4

The following code is given:

pythondct = dict(0='abc', 1='def')
print(dct)

Tell me what will be output to the console.