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