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