QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 77

Given def total(count, text): pass, what happens when total(1, count=2, text="x") is called?

  1. count becomes 2 because the keyword overrides 1.
  2. It raises TypeError because count receives two values.Ճիշտ պատասխան
  3. It succeeds only because text is supplied last.
  4. It raises ValueError because keyword order is wrong.

Բացատրություն

The positional argument already binds count, and count=2 attempts to bind that same parameter again, so the call raises TypeError. A keyword does not silently override a value already supplied by position.

Շարունակեք այս թեստով

Սկսել վարժանքը
Հարց 77: Given def total(count, text): pass, what happens when… · Python Fundamentals · Questena