Soru
How do you access the value of a key in a Python dictionary? (50 Points) [4] b) A list of dictionary keys. a) A list of dictionary values. d) A list of dictionary items and their data types. c) A list of key-value pairs.
Çözüm
4.5
(181 Oylar)
Leman
Usta · 5 yıl öğretmeni
Uzman doğrulaması
Cevap
To access the value of a key in a Python dictionary, you can use the following syntax:```pythonmy_dict = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}value = my_dict['key1']print(value) # Output: value1```In this example, `my_dict` is a dictionary containing three key-value pairs. To access the value associated with the key `'key1'`, you can use the syntax `my_dict['key1']`. This will return the value `'value1'`.So, the correct answer is:c) A list of key-value pairs.