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