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


A = [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]
[A[i][i] for i in range(len(A))]

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