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