Level 1 : What does the following code output?


def func(x, lst=[]):
    lst.append(x)
    return lst

print(func(10))
print(func(20, []))
print(func(30))

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