1. Home
  2. Data Science
  3. Python
  4. How do you access the value associated with the key 'age'…

Added 4 May 2024

How do you access the value associated with the key 'age' in a dictionary named person in Python?

  1. person['age'] Correct answer
  2. person.get('age')
  3. person.value('age')
  4. person[age]

Correct answer

A. person['age']

13 views

MCQSEXAM

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

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs