How do you access the value associated with the key 'age' in a dictionary named person in Python?
-
A
person['age']
Correct answer
-
B
person.get('age')
-
C
person.value('age')
-
D
person[age]
Correct answer
A. person['age']
13 views
Explanation
Dictionary values are accessed using keys, so person['age'] accesses the value associated with the key 'age'.
Doubts & discussion
Not sure why the answer is A? Ask here and get an explanation.
Ask a doubt about this MCQ