nerdexam
Python_Institute

PCEP-30-02 · Question #211

Select the true statement:

The correct answer is D. Keyword arguments cannot be followed by positional arguments. D is correct because Python enforces a strict rule: once you switch to keyword arguments in a function call, all remaining arguments must also be keyword arguments. Placing a positional argument after a keyword argument (e.g., func(x=1, 2)) raises a SyntaxError. Why the…

Question

Select the true statement:

Options

  • AYou cannot use a mix of positional and keyword argument passing.
  • BThe order of arguments passed does matter in keyword argument passing.
  • CThe order of arguments passed does not matter in positional argument passing.
  • DKeyword arguments cannot be followed by positional arguments.

How the community answered

(40 responses)
  • A
    3% (1)
  • B
    5% (2)
  • C
    13% (5)
  • D
    80% (32)

Explanation

D is correct because Python enforces a strict rule: once you switch to keyword arguments in a function call, all remaining arguments must also be keyword arguments. Placing a positional argument after a keyword argument (e.g., func(x=1, 2)) raises a SyntaxError.

Why the distractors are wrong:

  • A is false - Python absolutely allows mixing positional and keyword arguments (e.g., func(1, y=2)), provided positional ones come first.
  • B is false - the whole point of keyword arguments is that order doesn't matter; func(y=2, x=1) is the same as func(x=1, y=2).
  • C is false - positional arguments are order-dependent by definition; their position determines which parameter receives the value.

Memory tip: Think "positional before personal" - positional (anonymous) args must come before keyword (named) args, never after. If you've named one, all that follow must be named too.

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice