200-901 · Question #224
200-901 Question #224: Real Exam Question with Answer & Explanation
The correct answer is A: print(items.get('items')[0].get('page_id')). {"question_number": 2, "explanation": "In the script, 'items' is a dictionary with a key 'items' whose value is a LIST (array) of objects. To access the first element of that list, you must use index [0] (or .get with index notation). Once you have the first list element (a dict)
Question
Refer to the exhibit. Which command needs to be placed on the box where the code is missing to output the value of page_jd in the Python 3.7 script?
Options
- Aprint(items.get('items')[0].get('page_id'))
- Bprint(items.get('items').get('page_id'))
- Cprint(items['items']['page_id'].keys())
- Dprint(items['items']['page_id'])
Explanation
{"question_number": 2, "explanation": "In the script, 'items' is a dictionary with a key 'items' whose value is a LIST (array) of objects. To access the first element of that list, you must use index [0] (or .get with index notation). Once you have the first list element (a dict), you then call .get('page_id') to retrieve its value. Option B is wrong because it treats 'items' as a nested dict instead of a list. Options C and D use direct bracket notation on a list without indexing, which would raise a TypeError.", "generated_by": "claude-sonnet", "llm_judge_score": 4}
Topics
Community Discussion
No community discussion yet for this question.