Level 1 : What is the Output?


funcs = []
for i in range(3):
    funcs.append(lambda i=i: i)

print([f() for f in funcs])

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