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