Level 1 : What does the following code print?


def make_multiplier(n):
    return lambda x: x * n

double = make_multiplier(2)
triple = make_multiplier(3)

print(double(5), triple(5))

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