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