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

Inside a function body, count is assigned without any global or nonlocal declaration. How does Python normally classify count in that function?

  1. It automatically updates a same-named global.
  2. It is local to the function by default.Ճիշտ պատասխան
  3. Its scope is chosen after the function returns.
  4. It is local only when its value is mutable.

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

Assignment makes count a local name for that function unless a relevant declaration changes the scope rule. Python does not decide between local and global dynamically according to which branch happens to execute.

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

Սկսել վարժանքը
Հարց 82: Inside a function body, count is assigned without any… · Python Fundamentals · Questena