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