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