Level 1 : What is the output of the following code?


def func(x, lst=[]):
    lst.append(x)
    return lst

print(func(1))
print(func(2))

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