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