Level 2 : What is the output of the following code?


nums = [1, 2, 3, 4]
squared_nums = map(lambda x: x**2, nums)
print(list(squared_nums))

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