Level 1 : What will be the output of the following code?


def extendList(val, list=[]):
    list.append(val)
    return list

list1 = extendList(10)
list2 = extendList(123, [])
list3 = extendList('a')

print(list1)
print(list2)
print(list3)

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