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