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.5181 Voting
Leman
Usta · 5 yıl öğretmeniUzman doğrulaması
Cevap
To access the value of a key in a Python dictionary, you can use the following syntax:<br /><br />```python<br />my_dict = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}<br />value = my_dict['key1']<br />print(value) # Output: value1<br />```<br /><br />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'`.<br /><br />So, the correct answer is:<br />c) A list of key-value pairs.
Derecelendirmek için tıklayın: