200-901 Software Development and Design Practice Question
A Python script uses a dictionary to store device configuration parameters. Which key, if any, will raise a KeyError if it does not exist in the dictionary?
⚠ Common exam trap
Cisco often tests the distinction between direct dictionary access (which raises KeyError) and safe access methods like .get(), .setdefault(), and .pop() with defaults, trapping candidates who assume all dictionary access methods behave identically.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
config['timeout']
Using square bracket notation (config['timeout']) on a dictionary will raise a KeyError if the specified key does not exist. This is a fundamental behavior of Python dictionaries: direct key access without a fallback mechanism throws an exception when the key is missing.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
config.setdefault('timeout', 30)
Why it's wrong here
setdefault() adds the key with default value if missing, no error.
- ✓
config['timeout']
Why this is correct
Direct key access raises KeyError if the key does not exist.
- ✗
config.get('timeout')
Why it's wrong here
The .get() method safely returns None if key is absent.
- ✗
config.pop('timeout', None)
Why it's wrong here
pop() with default returns None if key missing, no error.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 200-901 question from scratch — 989 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.