Level 9 : What will be the output of the following Python program?


def foo(x):
    x[0] = ['def']
    x[1] = ['abc']
    return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))

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