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