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