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 | 1736+ Python FAQs | Share
operand | multiple-inheritance | slice | error | list-comprehension | dictionary | loops | input | iterable | filter-function | docstring | invalid-list | asyncio-module | sys | collection | descriptors | tuple-unpacking | application | call | operator-and | gil | class-and-object | operator-overloading | conversion | oops | command-line-parsing | list-vs-tuple | async | complex-number | bitwise-operator | loop | data_structure | function | control-flow | syntax-error | collections | round | comment | min-max-function | set-operation | list-indexing | exception-handling | print | match | functions | turtle | iterator | max-min | min-function | input-function | operators | math-copysign | classes | datetime | yield | list-operation | mapping-function | data-structure | def | logical-operator | comparison | operator-or | boolean-and-non-boolean | immutability | map-function | design-principle | access-modifier | regular-expression | else-statement | class-and-inheritance | identity-operator | typeerror | threading | identity-operator | swapping | formal-and-actual-parameter | assignment-operator | filter | memory-management | syntaxerror | integer | scientific-notation | escape-operator | input-function | global-variable | return-statement | destructor | expression | sorting | string-manipulation | control-statement | namedtuple | math | expand-tab | logical-operation | random-function | context-manager | copy | regex | file | file-handling | asyncio | __all__-attribute | global-variable | pep | postfix | error-handling | lists | numeric | version-check | class-and-instance-variable | dicts | logical-operator | module | built-in | datatype | string-formatting | list | tuple | update | benefit | rollback | string-slicing | python-django | dictionaries | range | memory | objects | default-mutable-argument | interpreter | bitwise | name-mangling | inheritance | functional-programming | python-repl | import-method | implementation | stack | string-formatting | goto-function | sum() | data-type | decimal | built-in-function | file_handling | exception-handling | lambda-function | generators-in-python | zfill-function | append | list-comprehension | arithmetic-operation | indexing | object-attribute | exponentiation | version | complex | set | while-and-for-loop | counter-function | mathematics | data-type | static-method | string | multithreading | type_conversion | deep-copy | pickling-&-unpickling | operations | decorator | recurssion | operator | polymorphism | matplotlib | __init_subclass__ | assert | precedence-and-associativity | magic-method | split | mathematical-function | sum-function | list-slicing | function-argument | inherit | floating-point-precision | condition | global-keyword | enumerate() | staticmethod | compute | mysql | fabs-function | choice | oop | debugging | heap-memory | generator | overflow | list-method | python_version | join | multiprocessing | indentation | methods | raise | string-slicing | identifier | higher-order-function | class | recursion | library | method | statement | constructor | loop-control | binary | array | data-structure | pseudocode | basic | keyword | id-function | round-function | matrix-list-comprehension | arithmetic-expression | python-history | string-method | frozenset | boolean | syntax-error | conditional-statement | syntax | variable | installation | nested-loop | sys-module | __future__ | exception | list-mutation | sorted | random | namespace | type-conversion | attribute | conditional-statement | with-statement | factorial-function | data-structures | built-in-function | mutable | center | string-iteration | zip | python | bitwise-operator | zip-function | package-management | parameter | thread | string-concatenation | print-statement | head-and-tail | virtual-environment | lambdas | software-design | comprehension | precedence | slicing | file-handling | pandas | python-module | format | touples | virtual-environment | counter | odd-number | immutable-data-type | list-join | init | shallow-copy | control-flow | type-conversion | global | function-and-scope | numpy | lambda | binary-operation | matrix | feature | for | int | string-method | while-else-loop | while-loop | encapsulation | generators | encoding ...