Courseiva

200-901 Software Development and Design Practice Question

A developer needs to create a Python function that accepts any number of keyword arguments and prints them. Which function definition correctly uses **kwargs?

⚠ Common exam trap

Cisco often tests the distinction between *args (positional arguments) and **kwargs (keyword arguments), and the trap here is that candidates confuse the single asterisk (*) for collecting keyword arguments instead of the double asterisk (**).

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

✓

def print_args(**kwargs): print(kwargs)

The **kwargs syntax in a Python function definition collects any number of keyword arguments into a dictionary. The function then prints that dictionary, which matches the requirement to accept and print any number of keyword arguments.

Answer analysis

Option-by-option breakdown

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

  • ✗

    def print_args(*args): print(args)

    Why it's wrong here

    *args collects positional arguments into a tuple, so keyword arguments such as name="Ada" raise TypeError instead of being captured. The double asterisk is required to pack keywords into a dictionary; *args would be the correct choice when the function must accept a variable number of positional values.

  • ✗

    def print_args(kwargs): print(kwargs)

    Why it's wrong here

    Without the double asterisk, kwargs is a single positional parameter, so callers cannot pass arbitrary keyword pairs and the function raises TypeError on unexpected keywords. The ** prefix is what packs keywords into a dictionary; the plain form would be correct only for one ordinary argument.

  • ✓

    def print_args(**kwargs): print(kwargs)

    Why this is correct

    The **kwargs syntax collects arbitrary keyword arguments into a dictionary named kwargs, which print then outputs. This satisfies the requirement to accept any number of keyword arguments, unlike *args, which gathers positional arguments into a tuple instead.

  • ✗

    def print_args(*kwargs): print(kwargs)

    Why it's wrong here

    Using *kwargs collects positional arguments into a tuple, so keyword arguments passed by name would raise a TypeError rather than being captured. The double asterisk is what packs named arguments into a dictionary. Single-asterisk *args is correct when a function must accept a variable number of unnamed positional values instead.

About these practice questions

This 200-901 question is part of Courseiva's 975-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.