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