Courseiva

200-901 Software Development and Design Practice Question

A developer is building a Python script that processes a list of network devices. Each device is represented as a dictionary with keys 'hostname' and 'ip'. The script must create a new list containing only the hostnames of devices whose IP address starts with '10.'. Which Python construct best accomplishes this in a single expression?

⚠ Common exam trap

The trap here is assuming that any loop that produces the correct output is equally valid, ignoring the explicit requirement for a single expression.

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

✓

A list comprehension with a conditional filter.

A list comprehension with a conditional filter is the most concise and Pythonic way to transform and filter a list in a single expression. It combines iteration, condition, and result construction, directly producing the required list of hostnames for devices whose IP starts with '10.'.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    A generator expression that yields all hostnames.

    Why it's wrong here

    A generator expression yields items lazily and would not directly produce a list unless wrapped in list(). Even then, it lacks the conditional filter needed to select only devices with IPs starting with '10.'. The stem requires a new list containing only specific hostnames, so a generator alone is insufficient.

  • ✗

    A for loop that appends to a new list.

    Why it's wrong here

    A for loop that appends to a new list would work, but it is not a single expression. The stem asks for the construct that best accomplishes the task in a single expression, making the comprehension more appropriate. The loop requires multiple lines and an explicit accumulator, which is less concise and more error-prone.

  • ✗

    A while loop with an index counter.

    Why it's wrong here

    A while loop with an index counter is unnecessarily complex and error-prone for iterating over a list of dictionaries. It does not provide a single-expression solution and requires manual index management, increasing the risk of off-by-one errors. It is not the best choice for this filtering task.

  • ✓

    A list comprehension with a conditional filter.

    Why this is correct

    A list comprehension with a conditional filter, such as [d['hostname'] for d in devices if d['ip'].startswith('10.')], directly produces the desired list in one readable expression. It iterates over the devices, applies the condition, and collects only the matching hostnames, avoiding the need for an explicit loop and append calls.

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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Cisco exam blueprint

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.