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