Level 5 : What will the following code output?


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

print(func(1))
print(func(2, []))
print(func(3))

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