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