Level 10 : What will be the output of the following code?


def outer():
    x = 5
    def inner():
        nonlocal x
        x = 10
    inner()
    return x

print(outer())

Author: VenuEmmela | Tags: function | 1736+ Python FAQs | Share
arithmetic-expression | precedence | classes | math | file-handling | frozenset | integer | goto-function | lambdas | sorted | global | int | operator-or | input-function | polymorphism | installation | filter | pickling-&-unpickling | head-and-tail | max-min | pep | software-design | random-function | generators | call | multithreading | fabs-function | destructor | function-argument | map-function | string-concatenation | filter-function | stack | sys | list-comprehension | keyword | tuple-unpacking | class | matrix | operator-overloading | identity-operator | application | assignment-operator | thread | lambda-function | id-function | string-slicing | operand | python-module | indexing | center | string-iteration | lists | global-keyword | sys-module | matplotlib | python-repl | loops | floating-point-precision | default-mutable-argument | mathematical-function | match | object-attribute | print | string-formatting | dictionary | static-method | overflow | global-variable | raise | list-join | regular-expression | mysql | append | namespace | iterator | expand-tab | parameter | immutability | compute | inheritance | zip-function | factorial-function | version | bitwise-operator | threading | docstring | operations | bitwise | scientific-notation | function-and-scope | generator | conversion | async | matrix-list-comprehension | functional-programming | python-django | multiprocessing | exception | update | magic-method | error | list-method | heap-memory | counter-function | odd-number | data_structure | string | list-mutation | mutable | conditional-statement | invalid-list | rollback | sum-function | slice | input | set-operation | numpy | print-statement | choice | syntax-error | built-in-function | while-else-loop | sorting | namedtuple | functions | round-function | syntaxerror | basic | file | min-function | join | logical-operator | encapsulation | exponentiation | access-modifier | attribute | formal-and-actual-parameter | debugging | mathematics | virtual-environment | precedence-and-associativity | zip | control-flow | higher-order-function | loop | nested-loop | string-method | iterable | virtual-environment | name-mangling | interpreter | file_handling | lambda | class-and-object | with-statement | type-conversion | format | copy | math-copysign | comment | oop | asyncio | design-principle | bitwise-operator | enumerate() | while-and-for-loop | turtle | min-max-function | init | loop-control | while-loop | feature | benefit | numeric | logical-operation | counter | collections | type_conversion | touples | recursion | library | data-structure | binary-operation | memory-management | slicing | range | function | string-formatting | datetime | escape-operator | variable | decimal | data-type | condition | boolean | input-function | comparison | split | regex | return-statement | error-handling | methods | dictionaries | class-and-instance-variable | command-line-parsing | control-statement | file-handling | built-in-function | built-in | complex-number | collection | list-vs-tuple | round | descriptors | comprehension | set | syntax-error | swapping | python_version | data-type | dicts | mapping-function | __all__-attribute | list-slicing | module | operator | indentation | package-management | generators-in-python | operator-and | import-method | postfix | string-method | pseudocode | constructor | data-structure | string-manipulation | boolean-and-non-boolean | yield | version-check | recurssion | deep-copy | __init_subclass__ | list-operation | identity-operator | staticmethod | inherit | list | complex | identifier | context-manager | string-slicing | operators | def | class-and-inheritance | random | method | memory | tuple | list-comprehension | zfill-function | arithmetic-operation | asyncio-module | gil | typeerror | for | implementation | multiple-inheritance | sum() | shallow-copy | python-history | data-structures | __future__ | type-conversion | global-variable | pandas | control-flow | encoding | array | exception-handling | list-indexing | python | decorator | conditional-statement | datatype | assert | immutable-data-type | oops | objects | binary | statement | syntax | expression | logical-operator | else-statement | exception-handling ...