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