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