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


def outer():
    x = 10
    def inner():
        print(x)
    return inner

fn = outer()
fn()

Author: KaivalyaG | Tags: function | 1859+ Python FAQs | Share
literal-characters-and-special-characters | numpy | logical-operators | polymorphism | list-vs-tuple | range | logical-operation | operator-and | list-slicing | head-and-tail | data-structures-in-python | python-django | bitwise-operator | escape-operator | factorial-function | using-join()-and-is_alive()-methods | arbitrary-arguments-(*args,-**kwargs) | thread-safe-data-structures-(queue.queue) | difference-between-threads-and-processes | filter | membership-operators-(in,-not-in) | thread-synchronization | built-in-function | higher-order-function | zip-function | list | strings | dictionary-methods | dictionary | destructor | identifier | statement | assignment-operator | update | complex | slicing | immutability | operator-or | oop | tuple-unpacking | identity-operator | walking-through-directories-using-os.walk() | overflow | command-line-parsing | python_version | type-conversion-and-casting | complex-number | advanced-file-operations | split | max-min | identity-operators-(is,-is-not) | comparison | __init_subclass__ | assert | indentation | set | using-os-and-pathlib-modules | list-comprehension | operator | loop | sum() | list-join | booleans | object-attribute | writing:-write(),-writelines() | while-and-for-loop | generators | exception-handling | objects | floating-point-precision | methods | scientific-notation | match | python-repl | pep | __all__-attribute | yield | math | asyncio | iterable | dictionaries | deep-copy | namedtuple | lambda-function | counter-function | control-statement | rollback | control-flow | working-with-binary-files-(rb,-wb) | defining-functions | string | namespace | magic-method | mathematics | exception | mathematical-function | odd-number | lambda | stack | syntax-error | random-function | creating-and-starting-threads | copy | introduction-to-threads | virtual-environment | print-statement | dictionary-comprehensions | string-manipulation | comprehension | control-flow | memory | mutable | method-overloading | functional-programming | compute | oops | counter | list-indexing | data-structures | recursion | regex | inherit | installation | conditional-statement | functions | using-assertions-(assertequal,-assertraises) | error | default-mutable-argument | why-use-multiprocessing-over-threading?-(gil) | test-discovery | string-iteration | file_handling | logical-operator | syntaxerror | precedence-and-associativity | multiple-inheritance | list-operation | parsing-with-strptime | indexing | version | global-variable | function | return-statement | datetime.date,-datetime.time,-datetime.datetime | operand | pass | file | reading-and-writing-large-files-efficiently | conditional-statement | string-slicing | integers | sys-module | directory-operations | regular-expressions | sets | loop-control-statements | datatype | constructor | data-structure | string-concatenation | nested-loop | immutable-data-type | decorator | format | condition | context-manager | while-loops | debugging | docstring | sorted | method | descriptors | __future__ | postfix | formal-and-actual-parameter | library | string-method | type-conversion | unit-testing | lambdas | data-type-conversions | arithmetic-operation | async | slice | classes | formatting-with-strftime | conditional-statements | choice | attribute | parameter | matrix | identity-operator | matrix-list-comprehension | frozenset | reading:-read(),-readline(),-readlines() | comment | collections | raise | thread | data-type | functional-programming | pandas | assignment-operators | time-series-with-pandas | type_conversion | turtle | anchors-(^,-$) | goto-function | data-structure | function-argument | joining-and-merging-dataframes | sum-function | datetime | string-formatting | working-with-dates-and-times | set-operation | syntax | print | file-handling | operator-overloading | built-in | operators | integer | list-comprehension | reading-and-writing-files | map-function | quantifiers-(*,-+,-?,-{}) | invalid-list | python | fabs-function | expression | name-mangling | conversion | multithreading | introduction-to-multiprocessing | pseudocode | handling-missing-values-(fillna,-dropna) | numeric | error-handling | global | exception-handling | data-type | dicts | decimal | binary | python-history | access-modifier | python-module | generator | raise-statement | pickling--unpickling | package-management | overriding-methods | python-operators | design-principle | for | creating-custom-modules | list-methods-and-slicing | expand-tab | input-function | opening-files-(open()) | precedence | encapsulation | binary-operation | math-copysign | managing-directories-with-os-and-shutil | default-arguments | operations | python-syntax-and-structure | list-mutation | min-function | collection | def | dataframe-and-series-objects | data_structure | indexing:-loc-vs-iloc | join | feature | data-types | random | multiprocessing | bitwise-operator | memory-management | loop-control | aggregating-data-with-functools.reduce() | list-method | class-and-inheritance | matplotlib | mapping-function | string-methods | logical-operator | import-method | loops | boolean-masking | using-else-and-finally | zip | sys | module | init | min-max-function | while-loop | threading | asyncio-module | application | type-conversion | lists | recurssion | list,-set,-and-dictionary-comprehensions | built-in-modules | global-keyword | implementation | floats | benefit | else | gil | heap-memory | array | mysql | exponentiation | while-else-loop | enumerate() | boolean-and-non-boolean | sorting | multiple-except-blocks | string-method | bitwise | string-formatting | round | tuple | boolean | call | list-comprehensions | input | version-check | using-lists-as-stacks | typeerror | class-and-object | virtual-environment | sorting-and-ranking | using-yield-in-functions | global-variable | filter-function | single-inheritance | staticmethod | error-handling | variable | built-in-function | center | file-handling | zfill-function | class-decorators | arithmetic-expression | using-map()-for-transformations | class | append | function-and-scope | lambda-functions | shallow-copy | class-and-instance-variable | else-statement | syntax-error | touples | interpreter | string-slicing | tuples | iterators | working-with-file-paths | int | regular-expression | encoding | introduction-to-python | working-with-temporary-files-using-tempfile | inheritance | id-function | intering | with-statement | generators-in-python | iterator | multiple-inheritance | keyword | software-design | filtering-and-indexing | static-method | tuple-methods | using-the-threading-module | key-value-pairs | round-function | input-function | basic | swapping ...