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