Informatics Practices

Write the output of the following code:

d = {'a':1, 'b':2, 'c':3}
print (d['a'])

Python Dictionaries

1 Like

Answer

1

Working

In the above code, d is a dictionary initialized with keys 'a', 'b', and 'c', each mapped to their respective values 1, 2, and 3. When print(d['a']) is executed, Python retrieves the value associated with the key 'a' from dictionary d. Therefore, the output of print(d['a']) will be 1.

Answered By

3 Likes


Related Questions