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