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


def f1(a,b=[]):
    b.append(a)
    return b
print(f1(2,[3,4]))

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