Level 10 : what is the output for the below code?


def outer_function(x):
    def inner_function(y):
        return x + y
    return inner_function

closure = outer_function(10)
result = closure(5)
print(result)

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