Courseiva

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 returns the existing value or inserts the default, so it never raises KeyError; the stem asks which key raises it. The method is tempting because it looks like safe lookup, but direct indexing with a missing key is what actually triggers KeyError.

  • ✓

    config['timeout']

    Why this is correct

    Subscript access on a dictionary raises KeyError when the requested key is absent; config['timeout'] therefore fails if 'timeout' was never inserted. The .get() method instead returns None, so bracket notation is the construct that satisfies the KeyError condition.

  • ✗

    config.get('timeout')

    Why it's wrong here

    dict.get() returns None (or a supplied default) for a missing key, so it never raises KeyError. It is tempting because it is the idiomatic way to read configuration values safely; however, the question asks which access raises KeyError, and only direct subscription such as config['timeout'] does that.

  • ✗

    config.pop('timeout', None)

    Why it's wrong here

    dict.pop() with a default argument returns None when the key is absent, raising nothing. It is tempting because pop removes and returns a value, useful for consuming one-time configuration entries; however, the question asks which access raises KeyError, and supplying the second argument suppresses that exception entirely.

About these practice questions

Courseiva writes every 200-901 question from scratch — 975 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 →

How Courseiva writes practice questions · Editorial policy

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.